SA-MP Forums Archive
Command doesn't remove the value - 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)
+--- Thread: Command doesn't remove the value (/showthread.php?tid=513370)



Command doesn't remove the value - DarkLored - 15.05.2014

I am making a pot smoking system but when i smoke it i don't lose the pots from my saving system i have checked everything in the saving system but everything seems to be fine also my animation doesn't work at all i am trying to make a animation that he will loop once but i cant seem to find the answer.

here is my code
pawn Код:
CMD:use(playerid,params[])
{
    new option[20],string[128];
    if(sscanf(params, "s[20]", option))
    {
        SendClientMessage(playerid,-1,"Available Options: pot,crack,materials,meth,heroin,radio,coldmeds.");
        SendClientMessage(playerid,-1,"Available Options: acid,seeds,pizza.");
        return 1;
    }
    if(!strcmp(option, "pot", true))
    {
        if(CantSmokePots[playerid] >= 1)
        {
            SendClientMessage(playerid,-1,"You already smoked some pots, please wait before doing it again.");
            return 1;
        }
        if(pInfo[playerid][pPot] == 0)
        {
           SendClientMessage(playerid,-1,"You don't have any pots to smoke..");
           return 1;
        }
        pInfo[playerid][pPot] -= 2;
        AddHealth(playerid,20);
        ApplyAnimation(playerid,"FOOD","EAT_burger",4.1,-1,-1,-1,-1,-1,-1);
        SendClientMessage(playerid,-1,"You have smoked 2 grams of pot.");
        format(string,sizeof(string),"*%s started to smoke some pots.",GetName(playerid));
        SendMessageToAllClosePlayers(playerid,COLOR_PURPLE,string);
        CantSmokePots[playerid] = 20;
        return 1;
    }
    if(!strcmp(option, "crack", true))
    {
        return 1;
    }
    return 1;
}



Re: Command doesn't remove the value - yvoms - 15.05.2014

change
Код:
        pInfo[playerid][pPot] -=2;
to
Код:
        pInfo[playerid][pPot] -2;



Re: Command doesn't remove the value - DarkLored - 16.05.2014

it gives me a warning that it doesn't have any effect and my way that i stated above is correct i just don't know why it doesn't work


Re : Command doesn't remove the value - Ramoboss - 16.05.2014

try :

pInfo[playerid][pPot] --;

or

PlayerInfo[playerid][pPot] --;


Re: Command doesn't remove the value - DarkLored - 16.05.2014

Nope that will decrease it in a unlimited matter -- is mostly used for timers.


Re : Command doesn't remove the value - Ramoboss - 16.05.2014

try it, i do like that in my gamemodes, and it works fine


Re: Command doesn't remove the value - DarkLored - 16.05.2014

it will only decrease by one and i want it to decrease by two and none of the ways above except mine seem to work but it still doesn't remove anything from the ini file


Re: Command doesn't remove the value - Threshold - 16.05.2014

Why would it change your .ini file? There is nothing in the code you posted that even saves anything to the ini file.
It most likely won't change the ini file until you disconnect, assuming you have some sort of SaveStats under OnPlayerDisconnect.


Re: Command doesn't remove the value - DarkLored - 16.05.2014

Nevermind forgot the saving part in the OnPlayerDisconnect.
Thanks for helping