SA-MP Forums Archive
Drugs & Mats bug - 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: Drugs & Mats bug (/showthread.php?tid=158102)



Drugs & Mats bug - Typhome - 08.07.2010

pawn Код:
if(strcmp(x_nr,"drugs",true) == 0)
            {
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /anna drugs [playerid/PartOfName] [amount]");
                    return 1;
                }
                giveplayerid = ReturnUser(tmp);
                if(IsPlayerConnected(giveplayerid))
                {
                    if(giveplayerid != INVALID_PLAYER_ID)
                    {
                        new Float:x, Float:y, Float:z;
                        GetPlayerPos(giveplayerid,x,y,z);
                        if(!PlayerToPoint(5, playerid, x, y, z))
                        {
                            SendClientMessage(playerid, COLOR_GRAD1, "   Player is not near you!");
                            return 1;
                        }
                        tmp = strtok(cmdtext, idx);
                        if(!strlen(tmp))
                        {
                            SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /anna drugs [playerid/PartOfName] [amount]");
                            return 1;
                        }
                        new asammount;
                        asammount = strval(tmp);
                        if(asammount >= PlayerInfo[playerid][pDrugs]) { SendClientMessage(playerid, COLOR_GREY, "   You don't have so many drugs."); return 1; }
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                        PlayerInfo[playerid][pDrugs] -= asammount;
                        PlayerInfo[giveplayerid][pDrugs] += asammount;
                        if(PlayerInfo[playerid][pSex] == 1) { format(string, sizeof(string), "* %s takes out his sack with drugs and hands it to %s.", sendername, giveplayer); }
                        else { format(string, sizeof(string), "* %s takes out her sack with drugs and hands it to %s.", sendername, giveplayer); }
                        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GRAD1, "   Player is Offline!");
                    return 1;
                }
            }
            else if(strcmp(x_nr,"mats",true) == 0)
            {
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /anna mats [playerid/PartOfName] [amount]");
                    return 1;
                }
                giveplayerid = ReturnUser(tmp);
                if(IsPlayerConnected(giveplayerid))
                {
                    if(giveplayerid != INVALID_PLAYER_ID)
                    {
                        new Float:x, Float:y, Float:z;
                        GetPlayerPos(giveplayerid,x,y,z);
                        if(!PlayerToPoint(5, playerid, x, y, z))
                        {
                            SendClientMessage(playerid, COLOR_GRAD1, "   Player is not near you!");
                            return 1;
                        }
                        tmp = strtok(cmdtext, idx);
                        if(!strlen(tmp))
                        {
                            SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /anna mats [playerid/PartOfName] [amount]");
                            return 1;
                        }
                        new adammount;
                        adammount = strval(tmp);
                        if(adammount >= PlayerInfo[playerid][pMats]) { SendClientMessage(playerid, COLOR_GREY, "   You don't have so many mats."); return 1; }
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                        PlayerInfo[playerid][pMats] -= adammount;
                        PlayerInfo[giveplayerid][pMats] += adammount;
                        if(PlayerInfo[playerid][pSex] == 1) { format(string, sizeof(string), "* %s vхtab taskust matsid ja ulatab matsid %s.", sendername, giveplayer); }
                        else { format(string, sizeof(string), "* %s vхtab taskust matsid ja ulatab matsid %s.", sendername, giveplayer); }
                        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GRAD1, "Mдngija ei ole aktiivine!");
                    return 1;
                }
            }
Like /give drugs (id) -9999999, then removes it.
But how disable it? It's same with mats (materials)


Re: Drugs & Mats bug - Typhome - 08.07.2010

Please help


Re: Drugs & Mats bug - Hiddos - 08.07.2010

pawn Код:
if(asammount < 0) return SendClientMessage(playerid,COLOR_GRAD1,"Enter a valid amount above 0!");



Re: Drugs & Mats bug - Typhome - 08.07.2010

But, when i have 100 drugs and i do
/give drugs (id) 100000000000000

then it gives? "Saying: You dont have many drugs!" ?


Re: Drugs & Mats bug - BP13 - 08.07.2010

Quote:
Originally Posted by Typhome
Посмотреть сообщение
But, when i have 100 drugs and i do
/give drugs (id) 100000000000000

then it gives? "Saying: You dont have many drugs!" ?
Because you don't have that much.


Re: Drugs & Mats bug - Hiddos - 08.07.2010

if(PlayerInfo[playerid][pDrugs] > asamount) bla;


Re: Drugs & Mats bug - Typhome - 08.07.2010

pawn Код:
if(strcmp(x_nr,"drugs",true) == 0)
            {
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /anna drugs [playerid/PartOfName] [amount]");
                    return 1;
                }
                giveplayerid = ReturnUser(tmp);
                if(IsPlayerConnected(giveplayerid))
                {
                    if(giveplayerid != INVALID_PLAYER_ID)
                    {
                        new Float:x, Float:y, Float:z;
                        GetPlayerPos(giveplayerid,x,y,z);
                        if(!PlayerToPoint(5, playerid, x, y, z))
                        {
                            SendClientMessage(playerid, COLOR_GRAD1, "   Player is not near you!");
                            return 1;
                        }
                        tmp = strtok(cmdtext, idx);
                        if(!strlen(tmp))
                        {
                            SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /anna drugs [playerid/PartOfName] [amount]");
                            return 1;
                        }
                        new asammount;
                        asammount = strval(tmp);
                        //if(asammount >= PlayerInfo[playerid][pDrugs]) { SendClientMessage(playerid, COLOR_GREY, "   You don't have so many drugs."); return 1; }
                        if(PlayerInfo[playerid][pDrugs] > asamount) return SendClientMessage(playerid,COLOR_GRAD1,"You dont have many drugs!");
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                        PlayerInfo[playerid][pDrugs] -= asammount;
                        PlayerInfo[giveplayerid][pDrugs] += asammount;
                        if(PlayerInfo[playerid][pSex] == 1) { format(string, sizeof(string), "* %s takes out his sack with drugs and hands it to %s.", sendername, giveplayer); }
                        else { format(string, sizeof(string), "* %s takes out her sack with drugs and hands it to %s.", sendername, giveplayer); }
                        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GRAD1, "   Player is Offline!");
                    return 1;
                }
            }
Right?


Re: Drugs & Mats bug - Typhome - 09.07.2010

Is that right, then?


Re: Drugs & Mats bug - oliverrud - 09.07.2010

Go test it and see for yourself?