Not setting a file variable to 0.
#1

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

Is the returned value 0?
Reply
#3

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

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);
}
Reply
#5

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


Forum Jump:


Users browsing this thread: 1 Guest(s)