HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Gold trading system

03-18-2004, 10:47 PM#1
fugly
yeah i am making a gold trading system in my map and i was wondering if i could make this coding any better, particularaly if i could make it so that you weren't forced to give a 3 digit number this is what i got going right now

Code:
    Events
        Player - Player 1 (Red) types a chat message containing -give as A substring
        Player - Player 2 (Blue) types a chat message containing -give as A substring
        Player - Player 3 (Teal) types a chat message containing -give as A substring
        Player - Player 4 (Purple) types a chat message containing -give as A substring
    Conditions
        ((Triggering player) Current gold) Greater than or equal to (Integer((Substring((Entered chat string), 6, 7))))
    Actions
        Set goldXfer[1] = (100 x (Integer((Substring((Entered chat string), 8, 8)))))
        Set goldXfer[2] = (10 x (Integer((Substring((Entered chat string), 9, 9)))))
        Set goldXfer[3] = (Integer((Substring((Entered chat string), 10, 10))))
        Set goldXfer[4] = (goldXfer[1] + (goldXfer[2] + goldXfer[3]))
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                goldXfer[4] Less than or equal to ((Triggering player) Current gold)
            Then - Actions
                Player - Add goldXfer[4] to (Random player from (All players matching ((Player number of (Matching player)) Equal to (Integer((Substring((Entered chat string), 6, 6))))))) Current gold
                Player - Set (Triggering player) Current gold to (((Triggering player) Current gold) - goldXfer[4])
                Game - Display to (All players) the text: ((PlayerNwC[(Player number of (Triggering player))] +  gave ) + (PlayerNwC[(Integer((Substring((Entered chat string), 6, 6))))] + (( |c00ff8000gold|r + (String(goldXfer[4]))) +  gold|r. |c0000ff00There is now a 2 second cooldown in effect for gold trading.|r)
            Else - Actions
        Trigger - Turn off (This trigger)
        Wait 2.00 seconds
        Trigger - Turn on (This trigger)

variabels are as follows:
PlayerNwC[x]: This is just the player's name with a color, the array number correspondes with the player number. ie.) Player1 account name is Ugly then "Ugly", in red text would appear, Player2's name is Pretty, then "Pretty" in blue text would appear
goldxfer[x]: 1 - 3 = the first diget, and so on | 4 = what the final number comes too.
03-18-2004, 11:06 PM#2
Bloodlust
I give you a hint: F11
03-18-2004, 11:39 PM#3
fugly
Quote:
Originally Posted by Bloodlust
I give you a hint: F11
If thats the trading screen, then nice try but no, the problem is that you can only trade 100 gold at a time, and do you think that i didn't concider that? and i know that a person can give change but what if by accident 2 people give him gold, and the right change can't be given. or the person is an ass and doesn't? All though these are unlikley they still happen, and triggers like these do the job of stopping these incedents
BTW: Here is a trigger that i was hoping that would work so that you can trade gold w/o HAVING to type in 3 interger, i just know that there is a way for it to be. and i think that the reason this doens't work is because since it can't recognize an integer it stops the whole trigger.
Code:
    Events
        Player - Player 1 (Red) types a chat message containing -give as A substring
        Player - Player 2 (Blue) types a chat message containing -give as A substring
        Player - Player 3 (Teal) types a chat message containing -give as A substring
        Player - Player 4 (Purple) types a chat message containing -give as A substring
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Integer((Substring((Entered chat string), 8, 8)))) Greater than or equal to 0
                (Integer((Substring((Entered chat string), 9, 9)))) Greater than or equal to 0
                (Integer((Substring((Entered chat string), 10, 10)))) Greater than or equal to 0
            Then - Actions
                Set goldXfer[1] = (100 x (Integer((Substring((Entered chat string), 8, 8)))))
                Set goldXfer[2] = (10 x (Integer((Substring((Entered chat string), 9, 9)))))
                Set goldXfer[3] = (Integer((Substring((Entered chat string), 10, 10))))
                Set goldXfer[4] = (goldXfer[1] + (goldXfer[2] + goldXfer[3]))
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        goldXfer[4] Less than or equal to ((Triggering player) Current gold)
                    Then - Actions
                        Player - Add goldXfer[4] to (Random player from (All players matching ((Player number of (Matching player)) Equal to (Integer((Substring((Entered chat string), 6, 6))))))) Current gold
                        Player - Set (Triggering player) Current gold to (((Triggering player) Current gold) - goldXfer[4])
                        Game - Display to (All players) the text: ((PlayerNwC[(Player number of (Triggering player))] +  gave ) + (PlayerNwC[(Integer((Substring((Entered chat string), 6, 6))))] + (( |c00ff8000gold|r + (String(goldXfer[4]))) +  gold|r. |c0000ff00There is now a 2 second cooldown in effect for gold trading.|r)
                        Trigger - Turn off (This trigger)
                        Wait 2.00 seconds
                        Trigger - Turn on (This trigger)
                    Else - Actions
                Skip remaining actions
            Else - Actions
                Do nothing
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Integer((Substring((Entered chat string), 8, 8)))) Greater than or equal to 0
                (Integer((Substring((Entered chat string), 9, 9)))) Greater than or equal to 0
            Then - Actions
                Set goldXfer[1] = (10 x (Integer((Substring((Entered chat string), 8, 8)))))
                Set goldXfer[2] = (1 x (Integer((Substring((Entered chat string), 9, 9)))))
                Set goldXfer[4] = (goldXfer[1] + goldXfer[2])
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        goldXfer[4] Less than or equal to ((Triggering player) Current gold)
                    Then - Actions
                        Player - Add goldXfer[4] to (Random player from (All players matching ((Player number of (Matching player)) Equal to (Integer((Substring((Entered chat string), 6, 6))))))) Current gold
                        Player - Set (Triggering player) Current gold to (((Triggering player) Current gold) - goldXfer[4])
                        Game - Display to (All players) the text: ((PlayerNwC[(Player number of (Triggering player))] +  gave ) + (PlayerNwC[(Integer((Substring((Entered chat string), 6, 6))))] + (( |c00ff8000gold|r + (String(goldXfer[4]))) +  gold|r. |c0000ff00There is now a 2 second cooldown in effect for gold trading.|r)
                        Trigger - Turn off (This trigger)
                        Wait 2.00 seconds
                        Trigger - Turn on (This trigger)
                    Else - Actions
                Skip remaining actions
            Else - Actions
                Do nothing
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Integer((Substring((Entered chat string), 8, 8)))) Greater than or equal to 0
            Then - Actions
                Set goldXfer[1] = (1 x (Integer((Substring((Entered chat string), 8, 8)))))
                Set goldXfer[4] = (goldXfer[1] + goldXfer[2])
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        goldXfer[4] Less than or equal to ((Triggering player) Current gold)
                    Then - Actions
                        Player - Add goldXfer[4] to (Random player from (All players matching ((Player number of (Matching player)) Equal to (Integer((Substring((Entered chat string), 6, 6))))))) Current gold
                        Player - Set (Triggering player) Current gold to (((Triggering player) Current gold) - goldXfer[4])
                        Game - Display to (All players) the text: ((PlayerNwC[(Player number of (Triggering player))] +  gave ) + (PlayerNwC[(Integer((Substring((Entered chat string), 6, 6))))] + (( |c00ff8000gold|r + (String(goldXfer[4]))) +  gold|r. |c0000ff00There is now a 2 second cooldown in effect for gold trading.|r)
                        Trigger - Turn off (This trigger)
                        Wait 2.00 seconds
                        Trigger - Turn on (This trigger)
                    Else - Actions
            Else - Actions
                Do nothing
03-18-2004, 11:44 PM#4
ThyFlame
You can change the increment per click.
03-19-2004, 12:02 AM#5
Lami
Maybe just do this:

instead of useing like 3 substrings, use 1!!!

u can do it so instead of a huge trigger u can make it so it is 9,13 or so!!!

U have 4 varables just to do 1 action when that is ont needed, you can do this (my 1 player version)

Event:
Player 1 types -give as a substring

Conditions:
players current gold is greaterthan of equal to Integer(string to integer(substring(entered Chat string)7,11)))

Substring(entered chat string)7,11 greaterthan 0

Action:
Add (-•(String to integer(Substring(entered chat string)7,11)) to player 1's current gold

Add (String to Integer(Substring(entered chat string)7,11) to (Convert Player Index to Player(string to integer(substring(entered chat string)13,13)'s current gold

Just to clairify -• means Negitive Times (x)
03-19-2004, 12:10 AM#6
fugly
you mean from 100 to 200?argg thats 2 spam posts in 1 thread
03-19-2004, 12:27 AM#7
Pheonix-IV
Quote:
Originally Posted by fugly
If thats the trading screen, then nice try but no, the problem is that you can only trade 100 gold at a time, and do you think that i didn't concider that? and i know that a person can give change but what if by accident 2 people give him gold, and the right change can't be given. or the person is an ass and doesn't? All though these are unlikley they still happen, and triggers like these do the job of stopping these incedents

That was hard...
03-19-2004, 12:35 AM#8
fugly
Quote:
Originally Posted by Pheonix-IV
That was hard...
Finanly an answer that isn't spam, Pheonix thx but i really want this system to work because if you change the increment to a small number, then later on your screwed with having to click too many times, or visa-versa, anyway i almost got this thing working, and since this is a 1 trigger system That needs only 1 variable i'll give it out for people to put into their maps easily.
03-19-2004, 12:48 AM#9
Lami
Whut? Did u read my trigger? ive tested it and it worked.

I think that is whut u were talking about =/

If not please Clairfy.

[edit] uhh ok, i think useing triggers is better if u set the number too high, you cant give it exactly but u can do it faster, triggers can be exact and quick,
-give 5000 3

will give 500 gold to teal! woo
03-19-2004, 01:01 AM#10
fugly
ok screw all that, everything is done and set and the trigger works. It requires only 1 variables thats an array. It only supports 1-9 player though and only 3 digit max trading, but your not forced to give a certain amount of digits. So all of these work.
-give2 157
-give2 15
-give2 1
You don't have to but -give2 015 and -give2 001 will also work
If you want the trigger for your map then tell me and i will post it.
03-19-2004, 01:53 AM#11
fugly
cause jass is to damn complicated for me
03-19-2004, 02:11 AM#12
fugly
thx, but my thing works now. lol sry
03-19-2004, 11:49 PM#13
Impdestroyer
hi im not that skilled with triggers to the point that i had a hard time geting grouped units to different regions so i was wondering if u could post a map with just that trigger on it and i would be eternally grateful.
03-20-2004, 02:59 AM#14
ThyFlame
Quote:
Originally Posted by fugly
Finanly an answer that isn't spam, Pheonix thx but i really want this system to work because if you change the increment to a small number, then later on your screwed with having to click too many times, or visa-versa, anyway i almost got this thing working, and since this is a 1 trigger system That needs only 1 variable i'll give it out for people to put into their maps easily.


I take great umbridge at that. Just because you don't understand the help you're being given doesn't mean you have the right to call our posts spam and unhelpful; either ask for clarification or use another suggestion.
03-20-2004, 03:10 PM#15
Impdestroyer
what ever one you feel works best or you could clarify how to in put the jass script or a combination of the two.


btw thanks for taken the time to help.