HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

give [playe color] [#] [resource] ???? how????

04-24-2003, 04:57 PM#1
Earth-Fury
im shure its custom text, please tell me, also a -give to [player color] (transfer control of selected unit[s]) trigger wild be apriciated aswell. please, dont noob up this topic =P
04-24-2003, 05:30 PM#2
MarSara
I wouldn't do this for player color, but rather player number. because when you do a comparison on a string it is case sensitive, so if a player typed "-give Red 1000" instead of "-give red 1000", noting will happen.
04-24-2003, 05:32 PM#3
Earth-Fury
ok, how i do it by player number?
04-24-2003, 05:53 PM#4
MarSara
ok here's the trigger to give resources:

(-give ## [amount] [gold/lumber])

Code:
function Trig_GiveResource_Conditions takes nothing returns boolean
    return SubStringBJ(GetEventPlayerChatString(), 1, 6) == "-give "
endfunction

function Trig_GiveResource_Actions takes nothing returns nothing
    local player who
    local integer index
    local integer add
    local integer amount

    set who = ConvertedPlayer(S2I(SubStringBJ(GetEventPlayerChatString(), 7, 9)))

    set index = 11
    set add = 1
    set amount = 0
    loop
        exitwhen add == 0
        set add = S2I(SubStringBJ(GetEventPlayerChatString(), index, index + 1))
        set amount = amount * 10 + add
        set index = index + 1
    endloop

    set index = index + 2
    if( SubString(GetEventPlayerChatString(), index, index + 4) == "Gold" ) then
        call AdjustPlayerStateBJ( amount, who, PLAYER_STATE_RESOURCE_GOLD )
    endif

    if( SubString(GetEventPlayerChatString(), index, index + 6) == "Lumber" ) then
        call AdjustPlayerStateBJ( amount, who, PLAYER_STATE_RESOURCE_LUMBER )
    endif
endfunction

//===========================================================================
function InitTrig_GiveResource takes nothing returns nothing
    set gg_trg_GiveResource = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_GiveResource, Player(0), " ", false )
    call TriggerAddCondition( gg_trg_GiveResource, Condition( function Trig_GiveResource_Conditions ) )
    call TriggerAddAction( gg_trg_GiveResource, function Trig_GiveResource_Actions )
endfunction

This should work, but didnt test it.
04-24-2003, 06:11 PM#5
Earth-Fury
ok, ill test it, thanks allot. can u do one for -giveto [player #]
04-24-2003, 06:16 PM#6
Earth-Fury
ack that has a compile error when i save the map >.< lol can yall fix it please? sorry to be a bother.

sashok20: please, dont be an ***.
04-24-2003, 11:27 PM#7
MarSara
I edited the post, you can try it again. I complied it and didn't get any errors this time.
04-25-2003, 01:32 AM#8
Earth-Fury
stll dosent compile for me. do i have to specificly name the trigger somthing? create variables? ext?
04-25-2003, 03:32 AM#9
SektorGaza
to show that I don't like to be called noob I made this program for you. :)

but you will see that my program is not perfect. In fact it sucks, but it does what you want it to do :)

only works for red though. so if you want it done for every player you need to change all variables and triggers for everyone.
04-25-2003, 03:35 AM#10
SektorGaza
oh and by the way, it doesnt check if you dont have enough gold or lumber to pay. so if you have

30 gold , and you said -give blue 3000 gold


it will just give away ur 30 and say that you paid 3000 :)
04-25-2003, 05:22 PM#11
Earth-Fury
then thats not what i wanted, i want it acesible for all players, without that bug..... is that too ****^%&^%&E$#%&# mutch to ask?
04-25-2003, 06:46 PM#12
SektorGaza
lol , you want me to do everything for you
04-25-2003, 07:27 PM#13
SektorGaza
OK, since Im a nice guy, and since I like to challenge myself, I did this thing. It all works now for all players.

I also fixed bugs. Ive addes test triggers if you want to really check if this works.

go on as red and give something to teal. then just type "teal" , you will see him properties.

or go on as teal and give something to red. then type "red"
you will see reds properties.

thats just to check if it really works. It works for every player.
04-25-2003, 08:03 PM#14
Earth-Fury
ok, a bit more complex than i was expecting, but, thanks. btw: i coulda done that with time =P what i Really wantted, was a singe trigger custom text script, but all the same.
04-25-2003, 08:08 PM#15
SektorGaza
I dont know, maybe there is a better way to do this. not involving so many variables, but its the way I did it.

have fun