• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Help With Jass Script

Status
Not open for further replies.
Level 3
Joined
Jan 31, 2008
Messages
66
hi can any jass experts help mi look at this script that i put in my edited dota map for banning global skills like thundergod's wrath and point out if there's any mistakes inside that makes the map lag out? :grin:
JASS:
globals
trigger BannedSkillTrigger=null
trigger BannedItemTrigger=null
trigger NoCrowUseDagonTrigger=null
endglobals
function BannedInit takes nothing returns nothing
if SubString(GetEventPlayerChatString(),0,8)=="-banlist" and GetTriggerPlayer()==Player(1) then
call DisplayTimedTextToForce(GetPlayersAll(),60,"|cff00ffffBanned Skills:Thundergod's Wrath, Heat Seeking Missile, March Of The Machines, Wrath Of Nature, Guardian Angel, Borrowed Time, Haunt, Last Word, Global Silence, Hand Of The God|r; |cffff3300Banned Items: Black King Bar, Linken's Sphere.|r")
if IsTriggerEnabled(BannedSkillTrigger)==false or IsTriggerEnabled(BannedSkillTrigger)==false then
call DisplayTimedTextToForce(GetPlayersAll(),2,"|cffff33ffTrigger Enabled!|r")
call EnableTrigger(BannedSkillTrigger)
call EnableTrigger(BannedItemTrigger)
endif
elseif SubString(GetEventPlayerChatString(),0,10)=="-crowdagon" and GetTriggerPlayer()==Player(1) then
call DisplayTimedTextToForce(GetPlayersAll(),60,"|cffff33ffCrow Using Dagon Has Been Banned, Please Abide By The Ban And Don't Use Crow With Dagon, Your Crow Will Be Killed If It Does!|r")
if IsTriggerEnabled(NoCrowUseDagonTrigger)==false then
call DisplayTimedTextToForce(GetPlayersAll(),2,"|cff00ffffTrigger Enabled!|r")
call EnableTrigger(NoCrowUseDagonTrigger)
endif
endif
if SubString(GetEventPlayerChatString(),0,10)=="-cleartext" then
if GetLocalPlayer()==GetTriggerPlayer() then
call ClearTextMessages()
endif 
endif
endfunction
function BannedSkillActions takes nothing returns nothing
local unit u=GetTriggerUnit()
if GetAbilityName(GetSpellAbilityId())=="Thundergod's Wrath" or GetAbilityName(GetSpellAbilityId())=="Heat Seeking Missile" or GetAbilityName(GetSpellAbilityId())=="March of the Machines" or GetAbilityName(GetSpellAbilityId())=="Wrath of Nature" or GetAbilityName(GetSpellAbilityId())=="Guardian Angel" then
call DisplayTextToForce(GetPlayersAll(),(GetPlayerName(GetOwningPlayer(u))+" has been killed for using |cff33ff00BANNED SKILLS!|r"))
call KillUnit(u)
elseif GetAbilityName(GetSpellAbilityId())=="Borrowed Time" or GetAbilityName(GetSpellAbilityId())=="Haunt" or GetAbilityName(GetSpellAbilityId())=="Last Word" or GetAbilityName(GetSpellAbilityId())=="Global Silence" or GetAbilityName(GetSpellAbilityId())=="Hand of God" then
call DisplayTextToForce(GetPlayersAll(),(GetPlayerName(GetOwningPlayer(u))+" has been killed for using |cff33ff00BANNED SKILLS!|r"))
call KillUnit(u)
endif
set u=null
endfunction
function BannedItemActions takes nothing returns nothing
local unit u=GetTriggerUnit()
if GetItemName(GetManipulatedItem())=="Linken's Sphere" then
call DisplayTextToForce(GetPlayersAll(),(GetPlayerName(GetOwningPlayer(u))+" tried to buy |cffff00ffLinken's Sphere!|r"))
call SetPlayerState(GetOwningPlayer(u),PLAYER_STATE_RESOURCE_GOLD,GetPlayerState(GetOwningPlayer(u),PLAYER_STATE_RESOURCE_GOLD)+5175)
call RemoveItem(GetManipulatedItem())
elseif GetItemName(GetManipulatedItem())=="Black King Bar" then
call DisplayTextToForce(GetPlayersAll(),(GetPlayerName(GetOwningPlayer(u))+" tried to buy |cffff00ffBlack King Bar!|r"))
call SetPlayerState(GetOwningPlayer(u),PLAYER_STATE_RESOURCE_GOLD,GetPlayerState(GetOwningPlayer(u),PLAYER_STATE_RESOURCE_GOLD)+3800)
call RemoveItem(GetManipulatedItem())
endif
set u=null
endfunction
function NoCrowUseDagonActions takes nothing returns nothing
local unit u=GetTriggerUnit()
if SubString(GetItemName(GetManipulatedItem()),0,5)==SubString("Dagon",0,5) and GetUnitName(u)== "Crow" then
call DisplayTextToForce(GetPlayersAll(),(GetPlayerName(GetOwningPlayer(u))+" Tried To Use Dagon With Crow, But His Crow Ended Up Being Killed! |cffff3333Grab The Dropped Dagon Now!|r"))
call KillUnit(u)
endif
set u=null
endfunction
function main takes nothing returns nothing
call TriggerAddAction(BANLIST,function BannedInit)
call TriggerRegisterPlayerChatEvent(BANLIST,Player(1),"-",false)
set BannedSkillTrigger=CreateTrigger()
call DisableTrigger(BannedSkillTrigger)
call TriggerRegisterPlayerUnitEvent(BannedSkillTrigger,Player(1),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
call TriggerRegisterPlayerUnitEvent(BannedSkillTrigger,Player(2),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
call TriggerRegisterPlayerUnitEvent(BannedSkillTrigger,Player(3),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
call TriggerRegisterPlayerUnitEvent(BannedSkillTrigger,Player(4),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
call TriggerRegisterPlayerUnitEvent(BannedSkillTrigger,Player(5),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
call TriggerRegisterPlayerUnitEvent(BannedSkillTrigger,Player(7),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
call TriggerRegisterPlayerUnitEvent(BannedSkillTrigger,Player(8),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
call TriggerRegisterPlayerUnitEvent(BannedSkillTrigger,Player(9),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
call TriggerRegisterPlayerUnitEvent(BannedSkillTrigger,Player(10),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
call TriggerRegisterPlayerUnitEvent(BannedSkillTrigger,Player(11),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
call TriggerAddAction(BannedSkillTrigger,function BannedSkillActions)
set BannedItemTrigger=CreateTrigger()
call DisableTrigger(BannedSkillTrigger)
call TriggerRegisterPlayerUnitEvent(BannedItemTrigger,Player(1),EVENT_PLAYER_UNIT_PICKUP_ITEM,null)
call TriggerRegisterPlayerUnitEvent(BannedItemTrigger,Player(2),EVENT_PLAYER_UNIT_PICKUP_ITEM,null)
call TriggerRegisterPlayerUnitEvent(BannedItemTrigger,Player(3),EVENT_PLAYER_UNIT_PICKUP_ITEM,null)
call TriggerRegisterPlayerUnitEvent(BannedItemTrigger,Player(4),EVENT_PLAYER_UNIT_PICKUP_ITEM,null)
call TriggerRegisterPlayerUnitEvent(BannedItemTrigger,Player(5),EVENT_PLAYER_UNIT_PICKUP_ITEM,null)
call TriggerRegisterPlayerUnitEvent(BannedItemTrigger,Player(7),EVENT_PLAYER_UNIT_PICKUP_ITEM,null)
call TriggerRegisterPlayerUnitEvent(BannedItemTrigger,Player(8),EVENT_PLAYER_UNIT_PICKUP_ITEM,null)
call TriggerRegisterPlayerUnitEvent(BannedItemTrigger,Player(9),EVENT_PLAYER_UNIT_PICKUP_ITEM,null)
call TriggerRegisterPlayerUnitEvent(BannedItemTrigger,Player(10),EVENT_PLAYER_UNIT_PICKUP_ITEM,null)
call TriggerRegisterPlayerUnitEvent(BannedItemTrigger,Player(11),EVENT_PLAYER_UNIT_PICKUP_ITEM,null)
call TriggerAddAction(BannedItemTrigger,function BannedItemActions)
set NoCrowUseDagonTrigger=CreateTrigger()
call DisableTrigger(NoCrowUseDagonTrigger)
call TriggerRegisterPlayerUnitEvent(NoCrowUseDagonTrigger,Player(1),EVENT_PLAYER_UNIT_USE_ITEM,null)
call TriggerRegisterPlayerUnitEvent(NoCrowUseDagonTrigger,Player(2),EVENT_PLAYER_UNIT_USE_ITEM,null)
call TriggerRegisterPlayerUnitEvent(NoCrowUseDagonTrigger,Player(3),EVENT_PLAYER_UNIT_USE_ITEM,null)
call TriggerRegisterPlayerUnitEvent(NoCrowUseDagonTrigger,Player(4),EVENT_PLAYER_UNIT_USE_ITEM,null)
call TriggerRegisterPlayerUnitEvent(NoCrowUseDagonTrigger,Player(5),EVENT_PLAYER_UNIT_USE_ITEM,null)
call TriggerRegisterPlayerUnitEvent(NoCrowUseDagonTrigger,Player(7),EVENT_PLAYER_UNIT_USE_ITEM,null)
call TriggerRegisterPlayerUnitEvent(NoCrowUseDagonTrigger,Player(8),EVENT_PLAYER_UNIT_USE_ITEM,null)
call TriggerRegisterPlayerUnitEvent(NoCrowUseDagonTrigger,Player(9),EVENT_PLAYER_UNIT_USE_ITEM,null)
call TriggerRegisterPlayerUnitEvent(NoCrowUseDagonTrigger,Player(10),EVENT_PLAYER_UNIT_USE_ITEM,null)
call TriggerRegisterPlayerUnitEvent(NoCrowUseDagonTrigger,Player(11),EVENT_PLAYER_UNIT_USE_ITEM,null)
call TriggerAddAction(NoCrowUseDagonTrigger,function NoCrowUseDagonActions)
endfunction
 
Level 17
Joined
Jun 17, 2007
Messages
1,433
You should really use the Raw Data of the spells, because your names could easily be incorrect.

Thundergod's Wrath: A06L
Thundergod's Wrath(Scepter): A07C
Borrowed Time: A0NS
Nature's Wrath: A07X
Global Silence: A0L3
Last Word(it is passive remember, this is the silencing ability): A0LS
Heat Seeking Missile: A05E
MotM: A0BQ

The same goes with the items:

BKB: tdx2
Linken's Sphere: hslv
 
Level 3
Joined
Jan 31, 2008
Messages
66
wow u said that so easily, but u can't access a dota map in world editor... :grin: nad the line : if GetLocalPlayer()=GetTriggerPlayer() then do actions doesn't function well, it makes mi lag out of online matches..... all the other players will see that i left the game first, then i see all other players leave the game at the same time....:cry:
 
Level 5
Joined
Aug 16, 2007
Messages
149
try to indent your code anyway, as it makes it incredibly hard to read if it all starts in the same place.
 
Level 3
Joined
Jan 31, 2008
Messages
66
ok sorry :razz: here it is, the indented triggers:
JASS:
globals
    trigger BANLIST=CreateTrigger()
    trigger BannedSkillTrigger=null
    trigger BannedItemTrigger=null
    trigger NoCrowUseDagonTrigger=null
endglobals
function BannedInit takes nothing returns nothing
    if SubString(GetEventPlayerChatString(),0,8)=="-banlist" and GetTriggerPlayer()==Player(1) then
        call DisplayTimedTextToForce(GetPlayersAll(),60,"|cff00ffffBanned Skills:Thundergod's Wrath, Heat Seeking Missile, March Of The Machines, Wrath Of Nature, Guardian Angel, Borrowed Time, Haunt, Last Word, Global Silence, Hand Of The God|r; |cffff3300Banned Items: Black King Bar, Linken's Sphere.|r")
        if IsTriggerEnabled(BannedSkillTrigger)==false or IsTriggerEnabled(BannedSkillTrigger)==false then
            call DisplayTimedTextToForce(GetPlayersAll(),2,"|cffff33ffTrigger Enabled!|r")
            call EnableTrigger(BannedSkillTrigger)
            call EnableTrigger(BannedItemTrigger)
        endif
    elseif SubString(GetEventPlayerChatString(),0,10)=="-crowdagon" and GetTriggerPlayer()==Player(1) then
        call DisplayTimedTextToForce(GetPlayersAll(),60,"|cffff33ffCrow Using Dagon Has Been Banned, Please Abide By The Ban And Don't Use Crow With Dagon, Your Crow Will Be Killed If It Does!|r")
        if IsTriggerEnabled(NoCrowUseDagonTrigger)==false then
            call DisplayTimedTextToForce(GetPlayersAll(),2,"|cff00ffffTrigger Enabled!|r")
            call EnableTrigger(NoCrowUseDagonTrigger)
        endif
    endif
    if SubString(GetEventPlayerChatString(),0,10)=="-cleartext" then
        call ClearTextMessages()
    endif
endfunction
function BannedSkillActions takes nothing returns nothing
    local unit u=GetTriggerUnit()
    if GetSpellAbilityId()==1093678915 or GetSpellAbilityId()==1093678668 or GetSpellAbilityId()==1093678936 or GetSpellAbilityId()==1093681484 or GetSpellAbilityId()==1093682514 or GetSpellAbilityId()==1093684308 then
        call DisplayTextToForce(GetPlayersAll(),(GetPlayerName(GetOwningPlayer(u))+" has been killed for using |cff33ff00BANNED SKILLS!|r"))
        call KillUnit(u)
    elseif GetSpellAbilityId()==1093684819 or GetSpellAbilityId()==1093678405 or GetSpellAbilityId()==1093681745 or GetSpellAbilityId()==1093683287 or GetSpellAbilityId()==1093683257 or GetSpellAbilityId()==1093684275 then
        call DisplayTextToForce(GetPlayersAll(),(GetPlayerName(GetOwningPlayer(u))+" has been killed for using |cff33ff00BANNED SKILLS!|r"))
        call KillUnit(u)
    endif
    set u=null
endfunction
function BannedItemActions takes nothing returns nothing
    local unit u=GetTriggerUnit()
    if GetItemTypeId(GetManipulatedItem())==1803117164 then
        call DisplayTextToForce(GetPlayersAll(),(GetPlayerName(GetOwningPlayer(u))+" tried to buy |cffff00ffLinken's Sphere!|r"))
        call SetPlayerState(GetOwningPlayer(u),PLAYER_STATE_RESOURCE_GOLD,GetPlayerState(GetOwningPlayer(u),PLAYER_STATE_RESOURCE_GOLD)+5175)
        call RemoveItem(GetManipulatedItem())
    elseif GetItemTypeId(GetManipulatedItem())==1868984943 then
        call DisplayTextToForce(GetPlayersAll(),(GetPlayerName(GetOwningPlayer(u))+" tried to buy |cffff00ffBlack King Bar!|r"))
        call SetPlayerState(GetOwningPlayer(u),PLAYER_STATE_RESOURCE_GOLD,GetPlayerState(GetOwningPlayer(u),PLAYER_STATE_RESOURCE_GOLD)+3800)
        call RemoveItem(GetManipulatedItem())
    endif
    set u=null
endfunction
function NoCrowUseDagonActions takes nothing returns nothing
    local unit u=GetTriggerUnit()
    if GetSpellAbilityId()==1093677647 or GetSpellAbilityId()==1093679193 or GetSpellAbilityId()==1093679194 or GetSpellAbilityId()==1093679408 or GetSpellAbilityId()==1093679410 and GetUnitTypeId(u)==1697657160 then
        call DisplayTextToForce(GetPlayersAll(),(GetPlayerName(GetOwningPlayer(u))+" Tried To Use Dagon With Crow, But His Crow Ended Up Being Killed! |cffff3333Grab The Dropped Dagon Now!|r"))
        call KillUnit(u)
    endif
    set u=null
endfunction
function main takes nothing returns nothing
    call TriggerAddAction(BANLIST,function BannedInit)
    call TriggerRegisterPlayerChatEvent(BANLIST,Player(1),"-",false)
    set BannedSkillTrigger=CreateTrigger()
    call DisableTrigger(BannedSkillTrigger)
    call TriggerRegisterPlayerUnitEvent(BannedSkillTrigger,Player(1),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
    call TriggerRegisterPlayerUnitEvent(BannedSkillTrigger,Player(2),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
    call TriggerRegisterPlayerUnitEvent(BannedSkillTrigger,Player(3),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
    call TriggerRegisterPlayerUnitEvent(BannedSkillTrigger,Player(4),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
    call TriggerRegisterPlayerUnitEvent(BannedSkillTrigger,Player(5),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
    call TriggerRegisterPlayerUnitEvent(BannedSkillTrigger,Player(7),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
    call TriggerRegisterPlayerUnitEvent(BannedSkillTrigger,Player(8),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
    call TriggerRegisterPlayerUnitEvent(BannedSkillTrigger,Player(9),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
    call TriggerRegisterPlayerUnitEvent(BannedSkillTrigger,Player(10),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
    call TriggerRegisterPlayerUnitEvent(BannedSkillTrigger,Player(11),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
    call TriggerAddAction(BannedSkillTrigger,function BannedSkillActions)
    set BannedItemTrigger=CreateTrigger()
    call DisableTrigger(BannedItemTrigger)
    call TriggerRegisterPlayerUnitEvent(BannedItemTrigger,Player(1),EVENT_PLAYER_UNIT_PICKUP_ITEM,null)
    call TriggerRegisterPlayerUnitEvent(BannedItemTrigger,Player(2),EVENT_PLAYER_UNIT_PICKUP_ITEM,null)
    call TriggerRegisterPlayerUnitEvent(BannedItemTrigger,Player(3),EVENT_PLAYER_UNIT_PICKUP_ITEM,null)
    call TriggerRegisterPlayerUnitEvent(BannedItemTrigger,Player(4),EVENT_PLAYER_UNIT_PICKUP_ITEM,null)
    call TriggerRegisterPlayerUnitEvent(BannedItemTrigger,Player(5),EVENT_PLAYER_UNIT_PICKUP_ITEM,null)
    call TriggerRegisterPlayerUnitEvent(BannedItemTrigger,Player(7),EVENT_PLAYER_UNIT_PICKUP_ITEM,null)
    call TriggerRegisterPlayerUnitEvent(BannedItemTrigger,Player(8),EVENT_PLAYER_UNIT_PICKUP_ITEM,null)
    call TriggerRegisterPlayerUnitEvent(BannedItemTrigger,Player(9),EVENT_PLAYER_UNIT_PICKUP_ITEM,null)
    call TriggerRegisterPlayerUnitEvent(BannedItemTrigger,Player(10),EVENT_PLAYER_UNIT_PICKUP_ITEM,null)
    call TriggerRegisterPlayerUnitEvent(BannedItemTrigger,Player(11),EVENT_PLAYER_UNIT_PICKUP_ITEM,null)
    call TriggerAddAction(BannedItemTrigger,function BannedItemActions)
    set NoCrowUseDagonTrigger=CreateTrigger()
    call DisableTrigger(NoCrowUseDagonTrigger)
    call TriggerRegisterPlayerUnitEvent(NoCrowUseDagonTrigger,Player(1),EVENT_PLAYER_UNIT_SPELL_CAST,null)
    call TriggerRegisterPlayerUnitEvent(NoCrowUseDagonTrigger,Player(2),EVENT_PLAYER_UNIT_SPELL_CAST,null)
    call TriggerRegisterPlayerUnitEvent(NoCrowUseDagonTrigger,Player(3),EVENT_PLAYER_UNIT_SPELL_CAST,null)
    call TriggerRegisterPlayerUnitEvent(NoCrowUseDagonTrigger,Player(4),EVENT_PLAYER_UNIT_SPELL_CAST,null)
    call TriggerRegisterPlayerUnitEvent(NoCrowUseDagonTrigger,Player(5),EVENT_PLAYER_UNIT_SPELL_CAST,null)
    call TriggerRegisterPlayerUnitEvent(NoCrowUseDagonTrigger,Player(7),EVENT_PLAYER_UNIT_SPELL_CAST,null)
    call TriggerRegisterPlayerUnitEvent(NoCrowUseDagonTrigger,Player(8),EVENT_PLAYER_UNIT_SPELL_CAST,null)
    call TriggerRegisterPlayerUnitEvent(NoCrowUseDagonTrigger,Player(9),EVENT_PLAYER_UNIT_SPELL_CAST,null)
    call TriggerRegisterPlayerUnitEvent(NoCrowUseDagonTrigger,Player(10),EVENT_PLAYER_UNIT_SPELL_CAST,null)
    call TriggerRegisterPlayerUnitEvent(NoCrowUseDagonTrigger,Player(11),EVENT_PLAYER_UNIT_SPELL_CAST,null)
    call TriggerAddAction(NoCrowUseDagonTrigger,function NoCrowUseDagonActions)
endfunction
can anyone tell mi or help i improve the script? hehe if it's lousy, please pardon my noobness... :grin:
 
Level 11
Joined
Aug 25, 2006
Messages
971
wow u said that so easily, but u can't access a dota map in world editor... :grin: nad the line : if GetLocalPlayer()=GetTriggerPlayer() then do actions doesn't function well, it makes mi lag out of online matches..... all the other players will see that i left the game first, then i see all other players leave the game at the same time....:cry:
I'm afraid no one on these forms can tell you how to unprotect a map. Not because they don't know, because it violates the website rules.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
GetLocalPlayer()==GetTriggerPlayer()

Obviously this causes you to drop in a multiplayer game as it allows one to run actions out of sync from other players. Thus anything that affects non graphic gameplay will cause you to be auto disconected as your instant of the game no longer matches other peoples instants of the game.

Basically, refrain from using it unless you have a slight idea what it does.
 
Status
Not open for further replies.
Top