Go ![]() | New ![]() | Find ![]() | Notify ![]() | Tools ![]() | Reply ![]() | |
| Peregrine |
What would be the best way to increment a variable by 1 when the picked up function is called? I've been trying Gold = Gold + 1; and Gold + 1 = GoldTotal but they are not working. I'm sure a local variable will work for saying the ammount of gold you carry, but will it also work if say I had a zoneinfo that had an if statement for a certain amount of gold being carried. | ||
|
| Treasurer |
Some context would help.Gold++; | |||
|
| Peregrine |
**falls over** | |||
|
| Peregrine |
Not working. No matter how many you pickup it always says you have 1 coin only. ================================================== //Pickup function function PickupFunction(Pawn Other) { local int Gold; local string PlayerName; local RunePlayer Player; Player = RunePlayer(Other); PlayerName = Player.PlayerReplicationInfo.PlayerName; Gold++; //the BroadcastMessage with current gold ammount BroadcastMessage(" "$PlayerName$" has "$Gold$" gold coins." ,false ,'Subtitle'); } ================================================== | |||
|
| Treasurer |
Originally posted by Methril:You've declared it locally; it will therefore initialize to zero with each call of the function. Declare it, rather, at the top of your class with a var int Gold; | |||
|
| Peregrine |
it doesnt work It does not work doing the exact same thing it was doing before. Staying as 1. | |||
|
| Emeritus |
seems appropriate here to try a few "if...else..." lines? will rune allow this? cumbersome and with heavy nwn "accent": in any case the above surely needs more parameters..please en-fleshen? i'm captivated by the elegance of 'var' though - i'll research it. | |||
|
| Peregrine |
Interesting, but don't you think it's a bit over the top? I mean we are just adding to one variable and then displaying it when the function is called. Maybe I just don't know what im doing. | |||
|
| Treasurer |
Originally posted by Methril:It looks like you're declaring the function in the gold piece itself; if that's the case, for each new gold piece you pick up the number will always be initialized to zero and return as one. Declare the variable in your pawn class and have each pawn store their own gold information. The call would then be, for instance: myPlayerPawn(Other).Gold++; BroadcastMessage(PlayerName @ "has" @ myPlayerPawn(Other).Gold @ "gold coins.", false, 'Subtitle'); | |||
|
| Powered by Social Strata |
| Please Wait. Your request is being processed... |
|
© Low Caliber Club 2002-4

