
Tid Bits of Info!
-Global array takes up 32kb, ouchies. -from Aero
-When using groups make sure to clear the units, destroy group, null group. -from HINDYhat
-To convert unittype Click here. -from HINDYhat
Systems
Aero's allying system=
Code: Select all
function GetBaseLength takes string s returns string
if SubString(s,0,5)=="-ally"then
return"5a"
elseif SubString(s,0,7)=="-unally"then
return"7b"
elseif SubString(s,0,7)=="-vision"then
return"7c"
elseif SubString(s,0,9)=="-unvision"then
return"9d"
endif
return""
endfunction
function AllyExecute takes nothing returns nothing
local integer i=0
local player p=GetTriggerPlayer()
local integer id=GetPlayerId(p)
local string s=GetEventPlayerChatString()
local string l=GetBaseLength(StringCase(s,false))
local string array n
local player t
if l!=""then
set i=S2I(SubString(l,0,1))+1
set l=SubString(l,1,2)
else
set p=null
return
endif
set n[0]="red"
set n[1]="blue"
set n[2]="teal"
set n[3]="purple"
set n[4]="yellow"
set n[5]="orange"
set n[6]="green"
set n[7]="pink"
set n[8]="gray"
set n[9]="light blue"
set n[10]="dark green"
set n[11]="brown"
set n[12]=StringCase(SubString(s,i,i+10),false)
set n[13]=""
set i=0
loop
if n[i]==n[12]then
set n[0]="exit"
endif
exitwhen n[0]=="exit"
set i=i+1
endloop
set t=Player(i)
if id==i then
call DisplayTextToPlayer(p,0,0,"You can't perform Alliance Operations with yourself!")
elseif i>11then
call DisplayTextToPlayer(p,0,0,"Invalid player color.")
elseif (l=="a")and(not GetPlayerAlliance(p,t,ALLIANCE_PASSIVE))then
call SetPlayerAllianceStateAllyBJ(p,t,true)
set n[13]=GetPlayerName(p)+" is now allies with "+GetPlayerName(t)
elseif (l=="b")and(GetPlayerAlliance(p,t,ALLIANCE_PASSIVE))then
call SetPlayerAllianceStateAllyBJ(p,t,false)
set n[13]=GetPlayerName(p)+" is now enemies with "+GetPlayerName(t)
elseif (l=="c")and(not GetPlayerAlliance(p,t,ALLIANCE_SHARED_VISION))then
call SetPlayerAlliance(p,t,ALLIANCE_SHARED_VISION,true)
set n[13]=GetPlayerName(p)+" is now sharing vision with "+GetPlayerName(t)
elseif (l=="d")and(GetPlayerAlliance(p,t,ALLIANCE_SHARED_VISION))then
call SetPlayerAlliance(p,t,ALLIANCE_SHARED_VISION,false)
set n[13]=GetPlayerName(p)+" is no longer sharing vision with "+GetPlayerName(t)
endif
call DisplayTextToPlayer(GetLocalPlayer(),0,0,n[13])
set p=null
set t=null
endfunction
//=======================================================================
function InitTrig_AllySystem takes nothing returns nothing
local integer i=0
local trigger t=CreateTrigger()
loop
exitwhen i>11
call TriggerRegisterPlayerChatEvent(t,Player(i),"-",false)
set i=i+1
endloop
call TriggerAddAction(t,function AllyExecute)
set t=null
endfunction
Code: Select all
function func takes nothing returns nothing
local integer i=1747988528 //unit type know idea how to figure out yet
local group g=CreateGroup()
local player p=Player(15)
loop
exitwhen i>1747988532
set bj_groupEnumTypeId=i
call GroupEnumUnitsOfPlayer(g,p,filterGetUnitsOfPlayerAndTypeId)
set bj_ghoul[i-1747988428]=FirstOfGroup(g)
call GroupClear(g)
set i=i+1
endloop
call DestroyGroup(g)
set g=null
set p=null
endfunction
Orginal Post
weirdone2 wrote:I'm having some trouble with my allying system so is it possible to convert color to string? Heres my codeCode: Select all
function Trig_ally_Actions takes nothing returns nothing local string s=GetEventPlayerChatString() local player p=GetTriggerPlayer() local integer i=StringLength(s) local string splayers=GetPlayerColor(p) if SubString(s,6,i)=="red" then call DisplayTextToPlayer(Player(0),0,0,splayers+"wishes to ally you, type -ally "+splayers+"to ally them") endif endfunction //=========================================================================== function InitTrig_ally takes nothing returns nothing local integer i=0 set gg_trg_ally = CreateTrigger() loop exitwhen i>10 call TriggerRegisterPlayerChatEvent(gg_trg_ally,Player(i),"-ally",false) set i=i+1 endloop call TriggerAddAction(gg_trg_ally,function Trig_ally_Actions) endfunction