• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Give Gold and / or Lumber System v 1.0.1.4

  • Like
Reactions: UndeadImmortal
This is a system that is simple to use. It allows you to use a custom lumber and / or gold give system in your map.

you can give it any command you want very simply. In the config trigger you simply type in the command that u want to trigger the give lumber and / or gold to another player.

These systems are separate. You dont need both for them to work. They are independant of one another.

Importing Steps
1) copy the config trigger first.
2) delete the variables that i put under the comments that said to delete them in the config trigger after posted.
3) copy the code trigger second.
4) set the string to what you want and try it out.

  • GiveGoldSystemConfig
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- This is the string command you want to activate the give gold. The capitilaztion matters for this code. so -giveGold and -givegold are different. --------
      • -------- I gave you the option to put a space after the give gold command. If you want -givegold to be the command then -givegold01 would give money to player 01 red. --------
      • -------- The reason this is -givegold01 is because i needed to add room for player 10 11 and 12. so this works for all players in game. --------
      • Set giveGoldString = -giveGold
      • -------- --------
      • -------- --------
      • -------- This allows you to tax the gold being traded. So lets say i give 100 gold to player 2 and the tax is 10% ( type in .10 for 10 percent) then i will lose 100 gold but only give player 2 90 gold. --------
      • Set giveGoldTax = 0.10
      • -------- --------
      • -------- --------
      • -------- Delete these variables after copying to ur map. --------
      • -------- --------
      • -------- --------
      • -------- This boolean lets u set if u want the player to be able to give gold. the index is for player red so player 1 gets the 1 index number. --------
      • -------- Make sure these are set to true in the variable editor. You can change these variables whenever you want and that player wont be able to give gold. --------
      • Set giveGoldBoolGiverPlayer[1] = True
      • -------- --------
      • -------- --------
      • -------- This boolean lets u set if u want the player to be able to recieve gold. the index is for player red so player 1 gets the 1 index number. --------
      • -------- Make sure these are set to true in the variable editor. You can change these variables whenever you want and that player wont be able to give gold. --------
      • Set giveGoldBoolReceivePlayer[1] = True
      • -------- --------
      • -------- --------
      • Set giveGoldLength1 = 0
      • Set giveGoldLength2 = 0
JASS:
    // Give Gold System v 1.0.1.4
    // by deathismyfriend

    function GiveGoldSystemActions takes nothing returns boolean
        local string entered
        local string sub1
        local integer recp // recieving player
        local integer money
        local integer p = GetPlayerId( GetTriggerPlayer())
        local integer i
        local playerstate psrg
        if udg_giveGoldBoolGiverPlayer[ p+1] then
            set entered = GetEventPlayerChatString()
            set sub1 = SubString( entered, 0, udg_giveGoldLength1)
            set recp = S2I( SubString( entered, udg_giveGoldLength1, udg_giveGoldLength2))
            if recp != p + 1 then
                if sub1 == udg_giveGoldString and udg_giveGoldBoolReceivePlayer[ recp] then
                    set money = S2I( SubString( entered, udg_giveGoldLength2, StringLength( entered)))
                    set psrg = PLAYER_STATE_RESOURCE_GOLD
                    set i = GetPlayerState( Player( p), psrg)
                    
                    if money < i then
                        call SetPlayerState( Player( recp), psrg, GetPlayerState( Player( recp), psrg) + R2I( I2R( money) * udg_giveGoldTax))
                    else
                        call SetPlayerState( Player( recp), psrg, GetPlayerState( Player( recp), psrg) + R2I( I2R( i) * udg_giveGoldTax))
                    endif
                    call SetPlayerState( Player( p), psrg, i - money)
                    set psrg = null
                endif
            endif
        endif
        return false
    endfunction

    function GiveGoldSystemSetup takes nothing returns nothing
        local trigger t = CreateTrigger()
        local integer L = 0
        local integer i = StringLength( udg_giveGoldString)
        loop
            exitwhen L > 11
            call TriggerRegisterPlayerChatEvent( t, Player( L), udg_giveGoldString, false)
            set L = L + 1
        endloop
        call TriggerAddCondition( t, Condition( function GiveGoldSystemActions))
        set udg_giveGoldLength1 = i
        set udg_giveGoldLength2 = i + 2
        set udg_giveGoldTax = 1.00 - udg_giveGoldTax
        call DestroyTimer( GetExpiredTimer())
        set t = null
    endfunction

    //===========================================================================
    function InitTrig_GiveGoldSystemCode takes nothing returns nothing
        call TimerStart( CreateTimer(), 0.00, false, function GiveGoldSystemSetup)
    endfunction

  • GiveLumberSystemConfig
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- This is the string command you want to activate the give lumber. The capitilaztion matters for this code. so -giveLumber and -givelumber are different. --------
      • -------- I gave you the option to put a space after the give Lumber command. If you want -giveLumber to be the command then -giveLumber01 would give money to player 01 red. --------
      • -------- The reason this is -giveLumber01 is because i needed to add room for player 10 11 and 12. so this works for all players in game. --------
      • Set giveLumberString = -giveLumber
      • -------- --------
      • -------- --------
      • -------- This allows you to tax the lumber being traded. So lets say i give 100 lumber to player 2 and the tax is 10% ( type in .10 for 10 percent) then i will lose 100 lumber but only give player 2 90 lumber. --------
      • Set giveLumberTax = 0.10
      • -------- --------
      • -------- --------
      • -------- Delete these variables after copying to ur map. --------
      • -------- --------
      • -------- --------
      • -------- This boolean lets u set if u want the player to be able to give lumber. the index is for player red so player 1 gets the 1 index number. --------
      • -------- Make sure these are set to true in the variable editor. You can change these variables whenever you want and that player wont be able to give lumber. --------
      • Set giveLumberBoolGiverPlayer[1] = True
      • -------- --------
      • -------- --------
      • -------- This boolean lets u set if u want the player to be able to recieve lumber. the index is for player red so player 1 gets the 1 index number. --------
      • -------- Make sure these are set to true in the variable editor. You can change these variables whenever you want and that player wont be able to give lumber. --------
      • Set giveLumberBoolReceivePlayer[1] = True
      • -------- --------
      • -------- --------
      • Set giveLumberLength1 = 0
      • Set giveLumberLength2 = 0
JASS:
    // Give Lumber System v 1.0.1.4
    // by deathismyfriend

    function GiveLumberSystemActions takes nothing returns boolean
        local string entered
        local string sub1
        local integer recp // recieving player
        local integer lumber
        local integer p = GetPlayerId( GetTriggerPlayer())
        local integer i
        local playerstate psrl
        if udg_giveLumberBoolGiverPlayer[ p+1] then
            set entered = GetEventPlayerChatString()
            set sub1 = SubString( entered, 0, udg_giveLumberLength1)
            set recp = S2I( SubString( entered, udg_giveLumberLength1, udg_giveLumberLength2))
            if recp != p + 1 then
                if sub1 == udg_giveLumberString and udg_giveGoldBoolReceivePlayer[ recp] then
                    set lumber = S2I( SubString( entered, udg_giveLumberLength2, StringLength( entered)))
                    set psrl = PLAYER_STATE_RESOURCE_LUMBER
                    set i = GetPlayerState( Player( p), psrl)
                    
                    if lumber < i then
                        call SetPlayerState( Player( recp), psrl, GetPlayerState( Player( recp), psrl) + R2I( I2R( lumber) * udg_giveLumberTax))
                    else
                        call SetPlayerState( Player(recp), psrl, GetPlayerState( Player( recp), psrl) + R2I( I2R( i) * udg_giveLumberTax))
                    endif
                    call SetPlayerState( Player( p), psrl, i - lumber)
                    set psrl = null
                endif
            endif
        endif
        return false
    endfunction

    function GiveLumberSystemSetup takes nothing returns nothing
        local trigger t = CreateTrigger()
        local integer L = 0
        local integer i = StringLength( udg_giveLumberString)
        loop
            exitwhen L > 11
            call TriggerRegisterPlayerChatEvent( t, Player( L), udg_giveLumberString, false)
            set L = L + 1
        endloop
        call TriggerAddCondition( t, Condition( function GiveLumberSystemActions))
        set udg_giveLumberLength1 = i
        set udg_giveLumberLength2 = i + 2
        call DestroyTimer( GetExpiredTimer())
        set t = null
    endfunction

    //===========================================================================
    function InitTrig_GiveLumberSystemCode takes nothing returns nothing
        call TimerStart( CreateTimer(), 0.00, false, function GiveLumberSystemSetup)
    endfunction



version 1.0.1.4
Made some improvements.​
version 1.0.1.3
Fixed a bug with giving gold to yourself.​
version 1.0.1.2
Fixed a huge bug with giving gold. It was giving gold to the wrong player b4.​
version 1.0.1.1
fixed a bug were useres without JNGP couldnt use this.
This can now be used by everyone.​
version 1.0.1.0
made changes to the code to allow for a more diverse approach.
you can now stop a player from recivieng or giving gold / lumber with a boolean.
One boolean for recieving and one boolean for giving gold / lumber
You can now put a tax on the gold / lumber that is traded.​
version 1.0.0.0
first version released​


Keywords:
GUI, GUI friendly, jass, give lumber, lumber, lumber system, give lumber system, deathismyfriend, dimf, give gold, gold, gold system, give gold system
Contents

Just another Warcraft III map (Map)

Reviews
15:56, 20th Aug 2013 PurgeandFire: Approved. Useful.
OK i switched this with the other one (i couldn't tell a difference in the scripts), should there be one for the gold pooling too?
So it looks to me like this is the same exact script or am i missing something?

In a more recent patch, 1.29 IIRC, the player count was bumped to twice what it was in the past. So I changed that part of this sctipt - a very minor change that was only needed because the author (like me) hardcoded the player count number instead of using the bj variable.
 
Top