Drugs & Mats bug
#1

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

Please help
Reply
#3

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

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

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

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.
Reply
#6

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

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

Is that right, then?
Reply
#9

Go test it and see for yourself?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)