wc3edit.net
https://forum.wc3edit.net/

I need help on trigger gold
http://forum.wc3edit.net/deprotection-cheating-f64/i-need-help-on-trigger-gold-t18040.html
Page 1 of 1

Author:  siverdragon12 [ July 18th, 2010, 2:58 am ]
Post subject:  I need help on trigger gold

I need a trigger like dota maps automatically increases each second gold and I can control the increasing amount of it and a command to turn it off and adjust the amount of gold per second increase

Look like money in the house elves and troll map

Link Map troll and elves :http://epicwar.com/maps/131465/

Thank you very much if someone help me

Author:  Ken [ July 18th, 2010, 4:03 am ]
Post subject:  Re: I need help on trigger gold

This is a pretty basic thing I whipped up in a few minutes. It initializes the var_income array such that each player gets 10 gold/sec, but you can create your own methods of changing the amount people get.
Spoiler:
Code:
globals
integer array var_income
endglobals
function func_giveIncome takes nothing returns nothing
local integer i = 0
loop
exitwhen i > 11
call SetPlayerState(Player(i),PLAYER_STATE_RESOURCE_GOLD,GetPlayerState(Player(i),PLAYER_STATE_RESOURCE_GOLD)+var_income[i])
set i = i + 1
endloop
endfunction
function func_initIncome takes nothing returns nothing
local timer loc_incomeTimer = CreateTimer()
local integer i = 0
loop
exitwhen i > 11
set var_income[i] = 10
set i = i + 1
endloop
call TimerStart(loc_incomeTimer,1.,true,function func_giveIncome)
endfunction
Just add "call initIncome()" to your function main, the rest of the stuff where it should go, and this should work fine.

Author:  siverdragon12 [ July 18th, 2010, 4:37 am ]
Post subject:  Re: I need help on trigger gold

Thanks Fatherspace :lol:
But I'm only able to get
And an activation command to start Gold trigger :razz:
Example :when I enter command -cheaton will enable cheat to me to continue and complete I type -gold in 1000 will automatically increase each second in 1000 when I enter the cheat-cheatoff will automatically turn off and I can adjust the amount of gold per second increases with the command -gold xxxx

Author:  haxorico [ July 18th, 2010, 7:42 am ]
Post subject:  Re: I need help on trigger gold

I didn't test it tough it should work...

Post this under globals
Spoiler:
Code:
integer array var_income
trigger time_cheat=CreateTrigger()

Post this under endglobals
Spoiler:
Code:
function func_giveIncome takes integer id returns nothing
local trigger t=CreateTrigger()
loop
exitwhen var_income[id+100]==0
call SetPlayerState(Player(id),PLAYER_STATE_RESOURCE_GOLD,GetPlayerState(Player(i),PLAYER_STATE_RESOURCE_GOLD)+var_income[id])
call TriggerSleepAction(1.00)
endloop
call DestroyTrigger(t)
endfunction



function func_activator takes nothing returns nothing
local player p=GetTriggerPlayer()
local integer id=GetPlayerId(p)
local string s=GetEventPlayerChatString()
local integer length=StringLength(s)
if SubString(s,0,length)=="-cheatson" and var_income[id+100]!=1 then
set var_income[id+100]=1
call func_giveIncome(id)
elseif SubString(s,0,length)=="-cheatsoff" and var_income[id+100]==1 then
set var_income[id+100]=0
elseif SubString(s,0,1)=="-"then
set var_income[id]=S2I(SubString(s,1,length))
endif
set p=null
set s=""
endfunction

Post this under function main
Spoiler:
Code:
local integer looper=0
loop
exitwhen looper==12
call TriggerRegisterPlayerChatEvent(time_cheat,Player(looper),"-",false)
set looper=looper+1
endloop
call TriggerAddAction(time_cheat,function func_activator)

There are 3 commands
-cheatson - activating it
-cheatsoff - deactivating it
-# - the number of gold you get every 1 second. so -3 = 3 gold per second

Have fun. Tell me if it doesn't work.

Author:  siverdragon12 [ July 18th, 2010, 11:39 am ]
Post subject:  Re: I need help on trigger gold

Thank you very much Fatherspace and haxorico

I am truly grateful
:razz:

Author:  naturesfury [ July 19th, 2010, 4:09 pm ]
Post subject:  Re: I need help on trigger gold

hmm o.o

i always wondered (and i didnt wanna open up a new thread for one basic question)....
why do you set some local variables to null and blank (basically erasing the data in it) when the function is over?
and why are some left as they are (ex: integer id and length in func_activator)?

Author:  haxorico [ July 20th, 2010, 11:53 am ]
Post subject:  Re: I need help on trigger gold

memory leaks.
integers and booleans dont leak as far as I know tough player and string variables do leak. So its like deleteting them

Author:  Ken [ July 20th, 2010, 4:37 pm ]
Post subject:  Re: I need help on trigger gold

It's not deleting them. Think of it like a variable being a box which can expand and contract to fit its contents, and you've got a thousand of those in a box that's a fixed size.

If you null and destroy, you empty the little boxes, so you have more space left in the big box.

What an awesome metaphor.

Author:  naturesfury [ July 23rd, 2010, 12:24 pm ]
Post subject:  Re: I need help on trigger gold

hmmm so.....a variable is a box (in your metaphor) that can expand and contract to fit w.e's in there
and there's a thousand of them....thats a FIXED size o.o
if u null/destroy and empty the little boxes....you have more space in the big box....
what is the little and big box o.o
theres only one size of box in this metaphor lol
the fixed size one xD

anyway....not to put u down or anything ^^ but yea i get it
ty ppls :D:D

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/