how to transfer gold/lumber to others player with command?

charzhai

New Member
Reaction score
2
i only can find out the income tax function and allies (F11) to transfer gold/lumber to others. except this method...is there any others way?

example : -gold pink 1000

to transfer 1000 gold to pink.
 

ianu74

New Member
Reaction score
8
Try this
Code:
Transfer Gold
    Events
        Player - Player 1 (Red) types a chat message containing -gold pink 1000 as An exact match
    Conditions
        (Player 1 (Red) Current gold) Greater than or equal to 1000
    Actions
        Player - Add -1000 to Player 1 (Red) Current gold
        Player - Add 1000 to Player 8 (Pink) Current gold
Try to use a Variable for the Gold transfering...
 

Terrabull

Veteran Member (Done that)
Reaction score
38
Code:
Help Trigger
    Events
        Player - Player 1 (Red) types a chat message containing -gold pink as A substring
    Conditions
    Actions
        Player - Add ((Integer((Substring((Entered chat string), 10, 15)))) x -1) to Player 1 (Red) Current gold
        Player - Add (Integer((Substring((Entered chat string), 10, 15)))) to Player 8 (Pink) Current gold

you can modify that to be used by several people, also add "if" statements to detect which player is being typed.
 

waaaks!

Zinctified
Reaction score
256
Code:
Help Trigger
    Events
        Player - Player 1 (Red) types a chat message containing -gold pink as A substring
    Conditions
    Actions
        Player - Add ((Integer((Substring((Entered chat string), 10, 15)))) x -1) to Player 1 (Red) Current gold
        Player - Add (Integer((Substring((Entered chat string), 10, 15)))) to Player 8 (Pink) Current gold

you can modify that to be used by several people, also add "if" statements to detect which player is being typed.

Terrabull you have missed the conditions...without conditions, player 1 red gives pink 1000 without decreasing player reds gold...:D
 

Arkan

Nobody rides for free
Reaction score
92
Here's a code I wrote for a TD I made which allows you to send gold to allies by typing -give #color #amount. If you don't have the gold you tried to send, you will send all the gold you have.

Make a trigger called "Give" with a capital G and convert it to custom script, remove all the code and paste this:

Code:
function Trig_Give_Actions takes nothing returns nothing
local player p=GetTriggerPlayer()
local integer gold=GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD)
local integer i
if SubStringBJ(GetEventPlayerChatString(),7,9)=="red" then
set i=S2I(SubStringBJ(GetEventPlayerChatString(),11,26))
if i>gold then
    set i=gold
endif
if i<0 then
    set i=0
endif
    if p==Player(0) then
    call DisplayTextToPlayer(p,0,0,"|cffFF0000You can't give money to yourself you tard!|r")
    else
    call DisplayTimedTextToForce(GetPlayersAll(),5,udg_PColor[GetPlayerId(p)]+GetPlayerName(p)+"|r just gave |cffFFFF00"+I2S(i)+"|r cash to "+udg_PColor[0]+GetPlayerName(Player(0))+"|r!")
    call SetPlayerStateBJ(Player(0),PLAYER_STATE_RESOURCE_GOLD,(GetPlayerState(Player(0),PLAYER_STATE_RESOURCE_GOLD)+i))
    call SetPlayerStateBJ(p,PLAYER_STATE_RESOURCE_GOLD,(GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD)-i))
    endif
    
elseif SubStringBJ(GetEventPlayerChatString(),7,10)=="blue" then
set i=S2I(SubStringBJ(GetEventPlayerChatString(),12,26))
if i>gold then
    set i=gold
endif
if i<0 then
    set i=0
endif
    if p==Player(1) then
    call DisplayTextToPlayer(p,0,0,"|cffFF0000You can't give money to yourself you tard!|r")
    else
    call DisplayTimedTextToForce(GetPlayersAll(),5,udg_PColor[GetPlayerId(p)]+GetPlayerName(p)+"|r just gave |cffFFFF00"+I2S(i)+"|r cash to "+udg_PColor[1]+GetPlayerName(Player(1))+"|r!")
    call SetPlayerStateBJ(Player(1),PLAYER_STATE_RESOURCE_GOLD,(GetPlayerState(Player(1),PLAYER_STATE_RESOURCE_GOLD)+i))
    call SetPlayerStateBJ(p,PLAYER_STATE_RESOURCE_GOLD,(GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD)-i))
    endif
    
elseif SubStringBJ(GetEventPlayerChatString(),7,10)=="teal" then
set i=S2I(SubStringBJ(GetEventPlayerChatString(),12,26))
if i>gold then
    set i=gold
endif
if i<0 then
    set i=0
endif
    if p==Player(2) then
    call DisplayTextToPlayer(p,0,0,"|cffFF0000You can't give money to yourself you tard!|r")
    else
    call DisplayTimedTextToForce(GetPlayersAll(),5,udg_PColor[GetPlayerId(p)]+GetPlayerName(p)+"|r just gave |cffFFFF00"+I2S(i)+"|r cash to "+udg_PColor[2]+GetPlayerName(Player(2))+"|r!")
    call SetPlayerStateBJ(Player(2),PLAYER_STATE_RESOURCE_GOLD,(GetPlayerState(Player(2),PLAYER_STATE_RESOURCE_GOLD)+i))
    call SetPlayerStateBJ(p,PLAYER_STATE_RESOURCE_GOLD,(GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD)-i))
    endif
    
elseif SubStringBJ(GetEventPlayerChatString(),7,12)=="purple" then
set i=S2I(SubStringBJ(GetEventPlayerChatString(),14,26))
if i>gold then
    set i=gold
endif
if i<0 then
    set i=0
endif
    if p==Player(3) then
    call DisplayTextToPlayer(p,0,0,"|cffFF0000You can't give money to yourself you tard!|r")
    else
    call DisplayTimedTextToForce(GetPlayersAll(),5,udg_PColor[GetPlayerId(p)]+GetPlayerName(p)+"|r just gave |cffFFFF00"+I2S(i)+"|r cash to "+udg_PColor[3]+GetPlayerName(Player(3))+"|r!")
    call SetPlayerStateBJ(Player(3),PLAYER_STATE_RESOURCE_GOLD,(GetPlayerState(Player(3),PLAYER_STATE_RESOURCE_GOLD)+i))
    call SetPlayerStateBJ(p,PLAYER_STATE_RESOURCE_GOLD,(GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD)-i))
    endif
    
elseif SubStringBJ(GetEventPlayerChatString(),7,12)=="yellow" then
set i=S2I(SubStringBJ(GetEventPlayerChatString(),14,26))
if i>gold then
    set i=gold
endif
if i<0 then
    set i=0
endif
    if p==Player(4) then
    call DisplayTextToPlayer(p,0,0,"|cffFF0000You can't give money to yourself you tard!|r")
    else
    call DisplayTimedTextToForce(GetPlayersAll(),5,udg_PColor[GetPlayerId(p)]+GetPlayerName(p)+"|r just gave |cffFFFF00"+I2S(i)+"|r cash to "+udg_PColor[4]+GetPlayerName(Player(4))+"|r!")
    call SetPlayerStateBJ(Player(4),PLAYER_STATE_RESOURCE_GOLD,(GetPlayerState(Player(4),PLAYER_STATE_RESOURCE_GOLD)+i))
    call SetPlayerStateBJ(p,PLAYER_STATE_RESOURCE_GOLD,(GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD)-i))
    endif
    
elseif SubStringBJ(GetEventPlayerChatString(),7,12)=="orange" then
set i=S2I(SubStringBJ(GetEventPlayerChatString(),14,26))
if i>gold then
    set i=gold
endif
if i<0 then
    set i=0
endif
    if p==Player(5) then
    call DisplayTextToPlayer(p,0,0,"|cffFF0000You can't give money to yourself you tard!|r")
    else
    call DisplayTimedTextToForce(GetPlayersAll(),5,udg_PColor[GetPlayerId(p)]+GetPlayerName(p)+"|r just gave |cffFFFF00"+I2S(i)+"|r cash to "+udg_PColor[5]+GetPlayerName(Player(5))+"|r!")
    call SetPlayerStateBJ(Player(5),PLAYER_STATE_RESOURCE_GOLD,(GetPlayerState(Player(5),PLAYER_STATE_RESOURCE_GOLD)+i))
    call SetPlayerStateBJ(p,PLAYER_STATE_RESOURCE_GOLD,(GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD)-i))
    endif
    
elseif SubStringBJ(GetEventPlayerChatString(),7,11)=="green" then
set i=S2I(SubStringBJ(GetEventPlayerChatString(),13,26))
if i>gold then
    set i=gold
endif
if i<0 then
    set i=0
endif
    if p==Player(6) then
    call DisplayTextToPlayer(p,0,0,"|cffFF0000You can't give money to yourself you tard!|r")
    else
    call DisplayTimedTextToForce(GetPlayersAll(),5,udg_PColor[GetPlayerId(p)]+GetPlayerName(p)+"|r just gave |cffFFFF00"+I2S(i)+"|r cash to "+udg_PColor[6]+GetPlayerName(Player(6))+"|r!")
    call SetPlayerStateBJ(Player(6),PLAYER_STATE_RESOURCE_GOLD,(GetPlayerState(Player(6),PLAYER_STATE_RESOURCE_GOLD)+i))
    call SetPlayerStateBJ(p,PLAYER_STATE_RESOURCE_GOLD,(GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD)-i))
    endif
    
elseif SubStringBJ(GetEventPlayerChatString(),7,10)=="pink" then
set i=S2I(SubStringBJ(GetEventPlayerChatString(),12,26))
if i>gold then
    set i=gold
endif
if i<0 then
    set i=0
endif
    if p==Player(7) then
    call DisplayTextToPlayer(p,0,0,"|cffFF0000You can't give money to yourself you tard!|r")
    else
    call DisplayTimedTextToForce(GetPlayersAll(),5,udg_PColor[GetPlayerId(p)]+GetPlayerName(p)+"|r just gave |cffFFFF00"+I2S(i)+"|r cash to "+udg_PColor[7]+GetPlayerName(Player(7))+"|r!")
    call SetPlayerStateBJ(Player(7),PLAYER_STATE_RESOURCE_GOLD,(GetPlayerState(Player(7),PLAYER_STATE_RESOURCE_GOLD)+i))
    call SetPlayerStateBJ(p,PLAYER_STATE_RESOURCE_GOLD,(GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD)-i))
    endif
    
elseif SubStringBJ(GetEventPlayerChatString(),7,10)=="gray" then
set i=S2I(SubStringBJ(GetEventPlayerChatString(),12,26))
if i>gold then
    set i=gold
endif
if i<0 then
    set i=0
endif
    if p==Player(8) then
    call DisplayTextToPlayer(p,0,0,"|cffFF0000You can't give money to yourself you tard!|r")
    else
    call DisplayTimedTextToForce(GetPlayersAll(),5,udg_PColor[GetPlayerId(p)]+GetPlayerName(p)+"|r just gave |cffFFFF00"+I2S(i)+"|r cash to "+udg_PColor[8]+GetPlayerName(Player(8))+"|r!")
    call SetPlayerStateBJ(Player(8),PLAYER_STATE_RESOURCE_GOLD,(GetPlayerState(Player(8),PLAYER_STATE_RESOURCE_GOLD)+i))
    call SetPlayerStateBJ(p,PLAYER_STATE_RESOURCE_GOLD,(GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD)-i))
    endif
    
elseif SubStringBJ(GetEventPlayerChatString(),7,15)=="lightblue" then
set i=S2I(SubStringBJ(GetEventPlayerChatString(),17,26))
if i>gold then
    set i=gold
endif
if i<0 then
    set i=0
endif
    if p==Player(9) then
    call DisplayTextToPlayer(p,0,0,"|cffFF0000You can't give money to yourself you tard!|r")
    else
    call DisplayTimedTextToForce(GetPlayersAll(),5,udg_PColor[GetPlayerId(p)]+GetPlayerName(p)+"|r just gave |cffFFFF00"+I2S(i)+"|r cash to "+udg_PColor[9]+GetPlayerName(Player(9))+"|r!")
    call SetPlayerStateBJ(Player(9),PLAYER_STATE_RESOURCE_GOLD,(GetPlayerState(Player(9),PLAYER_STATE_RESOURCE_GOLD)+i))
    call SetPlayerStateBJ(p,PLAYER_STATE_RESOURCE_GOLD,(GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD)-i))
    endif
    
elseif SubStringBJ(GetEventPlayerChatString(),7,15)=="darkgreen" then
set i=S2I(SubStringBJ(GetEventPlayerChatString(),17,26))
if i>gold then
    set i=gold
endif
if i<0 then
    set i=0
endif
    if p==Player(10) then
    call DisplayTextToPlayer(p,0,0,"|cffFF0000You can't give money to yourself you tard!|r")
    else
    call DisplayTimedTextToForce(GetPlayersAll(),5,udg_PColor[GetPlayerId(p)]+GetPlayerName(p)+"|r just gave |cffFFFF00"+I2S(i)+"|r cash to "+udg_PColor[10]+GetPlayerName(Player(10))+"|r!")
    call SetPlayerStateBJ(Player(10),PLAYER_STATE_RESOURCE_GOLD,(GetPlayerState(Player(10),PLAYER_STATE_RESOURCE_GOLD)+i))
    call SetPlayerStateBJ(p,PLAYER_STATE_RESOURCE_GOLD,(GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD)-i))
    endif
endif
set p=null
endfunction

//===========================================================================
function InitTrig_Give takes nothing returns nothing
    set gg_trg_Give = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent(gg_trg_Give,Player(0),"-give ",false)
    call TriggerRegisterPlayerChatEvent(gg_trg_Give,Player(1),"-give ",false)
    call TriggerRegisterPlayerChatEvent(gg_trg_Give,Player(2),"-give ",false)
    call TriggerRegisterPlayerChatEvent(gg_trg_Give,Player(3),"-give ",false)
    call TriggerRegisterPlayerChatEvent(gg_trg_Give,Player(4),"-give ",false)
    call TriggerRegisterPlayerChatEvent(gg_trg_Give,Player(5),"-give ",false)
    call TriggerRegisterPlayerChatEvent(gg_trg_Give,Player(6),"-give ",false)
    call TriggerRegisterPlayerChatEvent(gg_trg_Give,Player(7),"-give ",false)
    call TriggerRegisterPlayerChatEvent(gg_trg_Give,Player(8),"-give ",false)
    call TriggerRegisterPlayerChatEvent(gg_trg_Give,Player(9),"-give ",false)
    call TriggerRegisterPlayerChatEvent(gg_trg_Give,Player(10),"-give ",false)
    call TriggerAddAction( gg_trg_Give, function Trig_Give_Actions )
endfunction

The colors are: red, blue, teal, purple, yellow, orange, green, pink, gray, lightblue and darkgreen.
 

charzhai

New Member
Reaction score
2
error with the idea given

there is some error with undeclare identification...any other sugges pls?
 

charzhai

New Member
Reaction score
2
how to transfer gold with command?

Can anyone tell me how to transfer gold with command? with using variable.

exp : -gold red 1000

the user will send the 1000 gold to red...with condition as well...

thnx
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top