Problem with /give drugs command
#1

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;
				}
Reply
#2

pawn Код:
if(dammount > PlayerInfo[playerid][pDrugs] && dammount < 1 && dammount > 1000 )
Replace && with ||

pawn Код:
if(dammount > PlayerInfo[playerid][pDrugs] || dammount < 1 || dammount > 1000 )
Reply
#3

Thank you and Mike on IRC, got it fixed =)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)