new name[MAX_PLAYER_NAME], string{MAX_PLAYER_NAME] problem
#1

i wanna give one person this money based on their name... only problem is that when i put
new name[MAX_PLAYER_NAME], string[MAX_PLAYER_NAME];
at the top of the script with the other new items, it has trouble compiling. (it stops until i end the process... and then i'm left with a WORKING and compiled AMX script)
but if i put that exact line under OnPlayerSpawn with the rest of the code, it says possibly unintended assignment. i dont know wtf to do. i have isolated the problem to the "new name...." line.

here's the rest of the script:
format(personsmoney, sizeof(personsmoney), "/personsmoney.ini");
givemoney = dini_Int(personsmoney, "Money");
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(name, MAX_PLAYER_NAME, "%s");
if(name = "the_person") {GivePlayerMoney(playerid, givemoney), dini_IntSet(personsmoney, "Money", 0);}

also i had to be generic here of course i dont want to give away anyone's ID lol
can anyone help me?
Reply
#2

First of all strings, in your case the 'name' does not get compared with '==' there is strcmp for that, which returns a negative value if strings match.

So:
pawn Код:
if(strcmp(name,"the_person",false) == 0) {..}
Secondly you've mistook in placing a statement closing sign ( ';' ) in the end of your GivePlayerMoney statement.

pawn Код:
if(strcmp(name,"the_person",false) == 0) { GivePlayerMoney(playerid,givemoney); dini_IntSet(personsmoney,"Money",0);}
Reply
#3

i tried that, and it still doesnt wanna compile. like i said, whether u wanna argue, the code DID work. it just makes the compiler freeze until i decide to close it, meaning no error messages and no feedback to let me know if anything went wrong or not.

why do i need the string[MAX_PLAYER_NAME] there if i'm not going to use it now?

edit: nevermind, i moved the new name[MAX_PLAYER_NAME] line to OnPlayerSpawn with the rest of it. You are a genius.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)