Page 1 of 2

[HELP]Gold/Lumber Rate

Posted: June 9th, 2013, 6:51 pm
by zUsername
How to make custom commands to set gold/lumber rate for player?

Re: [HELP]Gold/Lumber Rate

Posted: June 9th, 2013, 7:50 pm
by haxorico
Ill explain the way I made for gold rate and you can mske it into lumber.

Make an integer variable holding the current amount of gold (make sn array if you want it for more than one player)

Make a trigger running everytime the gold amount changes.

Compare the new gold amount to the old gold amount.

If you see the gold increased, add more gold to the triggering player.
Make sure you disable the trigger before you add the gold so the trigger won't run infinitely. And turn it on when it's finished.

Re: [HELP]Gold/Lumber Rate

Posted: June 10th, 2013, 2:36 am
by zUsername
thanks Hax , I'll try now thanks for helping me .

Re: [HELP]Gold/Lumber Rate

Posted: June 10th, 2013, 5:48 pm
by zUsername
haxorico wrote:Ill explain the way I made for gold rate and you can mske it into lumber.

Make an integer variable holding the current amount of gold (make sn array if you want it for more than one player)

Make a trigger running everytime the gold amount changes.

Compare the new gold amount to the old gold amount.

If you see the gold increased, add more gold to the triggering player.
Make sure you disable the trigger before you add the gold so the trigger won't run infinitely. And turn it on when it's finished.


I create one integer variable with name Gold_Check then I set Gold_Check[triggerplayer...]=triggerplayer... current gold. As you said make trigger running everytime, I don't know what events I should choose. If I choose event every seconds, it's can't be use with triggerplayer.
And I think need to create 2 integer variables to holding amount of gold. 1 holding old gold amount , 1 holding new gold amount, then compare it. I'm understand what you says but I don't know how to make it. @@. I'm still noob.

Re: [HELP]Gold/Lumber Rate

Posted: June 11th, 2013, 5:07 am
by haxorico
There is an event regarding the resources changed. You can look at any rate edit cheatpack like sgguy fukki and mine.

Re: [HELP]Gold/Lumber Rate

Posted: June 11th, 2013, 4:20 pm
by zUsername

Code: Select all

globals
integer array VmFai
trigger array u7g_tmTp7
endglobals

function GoldConD takes player u7g_pp9,integer u7g_ii7,integer u7g_ss9 returns nothing
local integer u7g_ft7=VmFai[u7g_ii7+55]*(u7g_ss9-VmFai[u7g_ii7+79])
local integer u7g_goldwhee=u7g_ss9+u7g_ft7*3/20
call SetPlayerState(u7g_pp9,PLAYER_STATE_RESOURCE_GOLD,u7g_goldwhee)
endfunction

function Sg_Gold_hi7 takes nothing returns boolean
local playerstate u7g_bb9=PLAYER_STATE_RESOURCE_GOLD
local player u7g_pp9=GetTriggerPlayer()
local integer u7g_ii7=GetPlayerId(u7g_pp9)
local integer u7g_ss9=GetPlayerState(u7g_pp9,u7g_bb9)
if u7g_ss9>VmFai[u7g_ii7+79]then
if u7g_ss9-VmFai[u7g_ii7+79]>1then
call DisableTrigger(GetTriggeringTrigger())
call GoldConD(u7g_pp9,u7g_ii7,u7g_ss9)
set u7g_ss9=GetPlayerState(u7g_pp9,u7g_bb9)
call EnableTrigger(GetTriggeringTrigger())
endif
endif
set VmFai[u7g_ii7+79]=u7g_ss9
set u7g_pp9=null
set u7g_bb9=null
return false
endfunction

function Sg_Gold_Selection_Actions takes nothing returns nothing
local integer u7g_id5=GetPlayerId(GetTriggerPlayer())+48
local integer u7g_mnG=13
loop
exitwhen u7g_mnG>17
set u7g_tmTp7[u7g_id5]=CreateTrigger()
call TriggerAddCondition(u7g_tmTp7[u7g_id5],Condition(function Sg_Gold_hi7))
set VmFai[GetPlayerId(GetTriggerPlayer())+79]=GetPlayerState(GetTriggerPlayer(),PLAYER_STATE_RESOURCE_GOLD)
call TriggerRegisterPlayerStateEvent(u7g_tmTp7[u7g_id5],GetTriggerPlayer(),PLAYER_STATE_RESOURCE_GOLD,GREATER_THAN_OR_EQUAL,0)
set VmFai[GetPlayerId(GetTriggerPlayer())+55]=u7g_mnG-12
set u7g_mnG=u7g_mnG+1
endloop
endfunction

I'm extracted from SgGuyCP, it's working but when I killing unit, my resource gold will set to 10000000.
Please check my mistake. Thanks.

Re: [HELP]Gold/Lumber Rate

Posted: June 11th, 2013, 4:53 pm
by haxorico
A) If you post a code, please use the [code] tag
B) Reading from sgguy cp (and fai) is rather difficult for me as the variables have weird names so I will need to get home to read it properly.

Re: [HELP]Gold/Lumber Rate

Posted: June 11th, 2013, 5:15 pm
by zUsername
Ok, I'll wait for you . Thanks Hax.

Re: [HELP]Gold/Lumber Rate

Posted: June 14th, 2013, 8:36 am
by haxorico
Brief look and it seems you left out some parts.
What is calling the function sg_gold_selection_action

Re: [HELP]Gold/Lumber Rate

Posted: June 14th, 2013, 9:28 am
by zUsername
function main Hax