Problem with /give drugs command - 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: Problem with /give drugs command (
/showthread.php?tid=154944)
Problem with /give drugs command -
Kard0 - 16.06.2010
Well, I'm editing a LARP version to start out my scripting "career". I've been able to fix most of the bugs that have come across or have been reported to me by players, but I just can't get past this one. It lets players to give - drugs to another player, so that the player who gives - drugs gets some drugs to himself. I've tried numerous weird things against it, but it always lets to give -, I added, that the amount can't be under 1 or over 1000 but it still lets you to give llike -50 or around it aswell. Here is the code, I would be grateful if someone could give me some tips.
Код:
if(strcmp(x_nr,"narkootikumid",true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD1, "Kasutus: /anna narkootikumid [Mдngija ID/Osa nimest] [kogus]");
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, " Mдngija pole lдheduses!");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD1, "Kasutus: /anna narkootikumid [Mдngija ID/Osa nimest] [kogus]");
return 1;
}
new dammount;
dammount = strval(tmp);
if(dammount > PlayerInfo[playerid][pDrugs] && dammount < 1 && dammount > 1000 )
{ SendClientMessage(playerid, COLOR_GREY, " Sul pole nii palju narkootikume."); return 1; }
GetPlayerName(playerid, sendername, sizeof(sendername));
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
PlayerInfo[playerid][pDrugs] -= dammount;
PlayerInfo[giveplayerid][pDrugs] += dammount;
if(PlayerInfo[playerid][pSex] == 1) { format(string, sizeof(string), "* %s vхtab vдlja oma koti narkoga ja ulatab selle %s kдtte.", sendername, giveplayer); }
else { format(string, sizeof(string), "* %s vхtab vдlja oma koti narkoga ja ulatab selle %s kдtte.", sendername, giveplayer); }
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, " Mдngija pole sees!");
return 1;
}
Re: Problem with /give drugs command -
MadeMan - 16.06.2010
pawn Код:
if(dammount > PlayerInfo[playerid][pDrugs] && dammount < 1 && dammount > 1000 )
Replace && with ||
pawn Код:
if(dammount > PlayerInfo[playerid][pDrugs] || dammount < 1 || dammount > 1000 )
Re: Problem with /give drugs command -
Kard0 - 16.06.2010
Thank you and Mike on IRC, got it fixed =)