Set scriptfile from string
#1

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.
Reply
#2

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 ...
Reply
#3

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);".
Reply
#4

uff, thats beyond my knowledge. sry...
Reply
#5

Any Luck On This Yet? Ideas
Reply
#6

any updates on this
Reply
#7

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.
Reply
#8

any update that can help us out
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)