SA-MP Forums Archive
Bug in deposit! - 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: Bug in deposit! (/showthread.php?tid=274374)



Bug in deposit! - CJoao - 05.08.2011

when I use /deposit -10 I can get +10
Can someone explain me?
Sorry for my bad english!

Код:
	if(strcmp(cmd, "/Depositar", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	        if(IsPlayerInRangeOfPoint(playerid,5.0,BankPosition[X],BankPosition[Y],BankPosition[Z]))
	        {
				tmp = strtok(cmdtext, idx);
				if(!strlen(tmp))
				{
					SendClientMessage(playerid, COLOR_WHITE, "[Usage:] /Depositar [Quantidade]");
					return 1;
				}
				new cashdeposit = strval(tmp);
				if(!strlen(tmp))
				{
					SendClientMessage(playerid, COLOR_WHITE, "[Usage:] /Depositar [Quantidade]");
					return 1;
				}
				if(GetPlayerCash(playerid) >= cashdeposit)
				{
					GivePlayerCash(playerid,-cashdeposit);
					PlayerInfo[playerid][pBank]=cashdeposit+PlayerInfo[playerid][pBank];
					format(string, sizeof(string), "[Info:] Depositaste $%d, Novo balanзo: $%d", cashdeposit,PlayerInfo[playerid][pBank]);
					SendClientMessage(playerid, COLOR_WHITE, string);
                    PlayerActionMessage(playerid,15.0,"Entrega algum dinheiro ao banqueiro.");
                    OnPlayerDataSave(playerid);
					return 1;
				}
				else
				{
					SendClientMessage(playerid, COLOR_GREY, "[Erro:] Nгo tens esse dinheiro todo!");
				}
			}
			else
			{
			    SendClientMessage(playerid, COLOR_GREY, "[Erro:] Nгo estas no banco!");
			}
		}
		return 1;
	}



Re: Bug in deposit! - CJoao - 05.08.2011

i change
Код:
PlayerInfo[playerid][pBank]=cashdeposit+PlayerInfo[playerid][pBank];
to
Код:
PlayerInfo[playerid][pBank] += cashdeposit;
Continue with bug


Re: Bug in deposit! - MadeMan - 05.08.2011

pawn Код:
if(strcmp(cmd, "/Depositar", true) == 0)
    {
        if(IsPlayerInRangeOfPoint(playerid,5.0,BankPosition[X],BankPosition[Y],BankPosition[Z]))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_WHITE, "[Usage:] /Depositar [Quantidade]");
                return 1;
            }
            new cashdeposit = strval(tmp);
            if(cashdeposit < 1)
            {
                SendClientMessage(playerid, COLOR_GREY, "[Erro:] Invalid value!");
                return 1;
            }
            if(GetPlayerCash(playerid) >= cashdeposit)
            {
                GivePlayerCash(playerid,-cashdeposit);
                PlayerInfo[playerid][pBank]=cashdeposit+PlayerInfo[playerid][pBank];
                format(string, sizeof(string), "[Info:] Depositaste $%d, Novo balan?o: $%d", cashdeposit,PlayerInfo[playerid][pBank]);
                SendClientMessage(playerid, COLOR_WHITE, string);
                PlayerActionMessage(playerid,15.0,"Entrega algum dinheiro ao banqueiro.");
                OnPlayerDataSave(playerid);
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "[Erro:] N?o tens esse dinheiro todo!");
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "[Erro:] N?o estas no banco!");
        }
        return 1;
    }



Re: Bug in deposit! - CJoao - 05.08.2011

Work's Thx