SA-MP Forums Archive
Set scriptfile from string - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Set scriptfile from string (/showthread.php?tid=120491)



Set scriptfile from string - Mike Garber - 11.01.2010

How can I do so It takes money from scriptfile and then it sets it -amount on the other scriptfile?

I've set it up like,

pawn Код:
if(strcmp(cmd, "/payticket", true) == 0){
    new playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    new amount[256];
    new astring[64];
    amount = dini_Get("scriptfile", playername); // "scriptfile" is set to its real name in the script
    format(astring, sizeof(astring), "%d",amount);
    dini_IntSet("scriptfile2", playername, dini_Int("scriptfile2", playername)-amount); // "scriptfile2" is set to its real name in the script (This is where i get the error)
    return 1;
    }
Well, but I get this error (On the last line, before the return 1; )

Код:
error 033: array must be indexed (variable "amount")
Note, If it gives you more errors then I get, It's because this is not the whole commmand, just the part of it that I can't understand.
I understand the rest Of it and got it correct..

But you might get an idea how I'm thinking.


Re: Set scriptfile from string - Babul - 11.01.2010

the amount[] is defined as a string that needs to be parsed with %s , you are using %d , so you should convert the string to an integer with https://sampwiki.blast.hk/wiki/Strval ...



Re: Set scriptfile from string - Mike Garber - 12.01.2010

Quote:
Originally Posted by Babul
the amount[] is defined as a string that needs to be parsed with %s , you are using %d , so you should convert the string to an integer with https://sampwiki.blast.hk/wiki/Strval ...
That way I wont be able to have the amount set from the scriptfile... It will be preset in the script, wich I do not want.

Edit; It says empty statement when I modify It to work the way I want it.

Edit 2: Fixed that, now It says It must be a constant expression. I want it the integer to be "dini_Get("scriptfile", playername);".


Re: Set scriptfile from string - Babul - 12.01.2010

uff, thats beyond my knowledge. sry...


Re: Set scriptfile from string - gtapolicemods - 13.01.2010

Any Luck On This Yet? Ideas


Re: Set scriptfile from string - gtapolicemods - 07.02.2010

any updates on this


Re: Set scriptfile from string - mansonh - 07.02.2010

Basically amount is an array.
So you must use it as an array.
where is it defined? show that it should help us help you.



Re: Set scriptfile from string - br0adyb0ii - 19.02.2010

any update that can help us out