SA-MP Forums Archive
Not setting a file variable to 0. - 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: Not setting a file variable to 0. (/showthread.php?tid=120886)



Not setting a file variable to 0. - jameskmonger - 13.01.2010

pawn Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
  if(dialogid == 1 && response) // If the dialogid is 1 (our dialog) and they pressed 'Purchase'
  {
    new file[128];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
        format(file,sizeof(file),"SDM/Accounts/%s.ini",name);
    PlayerInfo[playerid][Deathstreak] = dini_Int(file, "Deathstreak");
    // We'll use the switch/cases now because we're going to process a few results, not just one. Remember, the first item in the list has id 0.
    switch(listitem)
    {
      case 0:
      {
        if(PlayerInfo[playerid][Deathstreak] == 2) return GivePlayerWeapon(playerid, 1, 1); SendClientMessage(playerid, COLOR_WHITE, "You have been given some brass knuckles as a death reward."); PlayerInfo[playerid][Deathstreak] = 0;
            SendClientMessage(playerid, COLOR_WHITE, "You don't have a high enough deathstreak. Go die some more.");
        }
      case 1:
      {
            if(PlayerInfo[playerid][Deathstreak] == 3) return GivePlayerWeapon(playerid, 2, 1); SendClientMessage(playerid, COLOR_WHITE, "You have been given a golf club as a death reward."); PlayerInfo[playerid][Deathstreak] = 0;
            SendClientMessage(playerid, COLOR_WHITE, "You don't have a high enough deathstreak. Go die some more.");
      }
      case 2:
      {
            if(PlayerInfo[playerid][Deathstreak] == 4) return GivePlayerWeapon(playerid, 3, 1); SendClientMessage(playerid, COLOR_WHITE, "You have been given a night stick as a death reward."); PlayerInfo[playerid][Deathstreak] = 0;
            SendClientMessage(playerid, COLOR_WHITE, "You don't have a high enough deathstreak. Go die some more.");
      }
  }
}
    return 1;
}
It loads from the file (I have a command shows an int from the file), but it doesn't put PlayerInfo[playerid][Deathstreak] to 0. Help?


Re: Not setting a file variable to 0. - Grim_ - 13.01.2010

Is the returned value 0?


Re: Not setting a file variable to 0. - jameskmonger - 13.01.2010

No, it's 4. When I do /deathstreak, it returns 4, but the dialog doesn't set it to 0. (Deathstreak tells you how many deaths in a row you've had.)


Re: Not setting a file variable to 0. - Babul - 13.01.2010

i suspect the return will abort your subroutine before you get the reward, and maybe not even the text will showup, coz its behind the return...
try that concept for just that case, if it works, modify the remaining too
Code:
case 0:
{
if(PlayerInfo[playerid][Deathstreak] == 2)
{
	SendClientMessage(playerid, COLOR_WHITE, "You have been given some brass knuckles as a death reward.");
	PlayerInfo[playerid][Deathstreak] = 0;
	return GivePlayerWeapon(playerid, 1, 1);
}



Re: Not setting a file variable to 0. - jameskmonger - 14.01.2010

It now doesn't give the reward if you have less than 2, but it doesn't remove it from your deathstreak.