Problem with Control Struckters
#1

Hello Guys,
I've a problem and hope you can help me.

I tried to make a different drugdealer-command. The player can only deal in his own turf/zone.
But when I am testing, nothing happens.

I tried it on two ways, but it doesn't want to work.

Here is the cmd:

Код:
	if(strcmp(cmd, "/dealen", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_LIGHTBLUE, "[BENUTZUNG:] /dealen [SpielerID/Name] [Anzahl]");
				return 1;
			}
			
			new Float:gzx, Float:gzy, Float:gzz; GetPlayerPos(playerid,gzx,gzy,gzz);
			for(new zone = 0; zone < MAX_ZONES; zone++)
			{
				if(gzx >= ZoneLocations[zone][0] && gzx < ZoneLocations[zone][2] && gzy >= ZoneLocations[zone][1] && gzy < ZoneLocations[zone][3])
				{
				  if(ZoneInfo[zone][ZoneOwnerID] != PlayerInfo[playerid][pFaction]) // falls der Dealer = GebietBesitzer
				  {
						SendClientMessage(playerid, COLOR_LIGHTRED, "[ERROR:] Du bist nicht in deinem Viertel!");
						return 1;
					}
				}
			}

			new playa;
			new needed;
			playa = ReturnUser(tmp);

			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
			  return 1;
			}

			needed = strval(tmp);
			if(needed < 1 || needed > 10)
			{
			  SendClientMessage(playerid, COLOR_LIGHTRED, "[ERROR:] Du kannst hцchstens 10 Gramm verticken");
			  return 1;
			}

			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
			  return 1;
			}
			
			if(needed > PlayerInfo[playerid][pGras])
			{
			  SendClientMessage(playerid, COLOR_LIGHTRED, "[ERROR:] Soviel hast du nicht!");
			  return 1;
			}
			
			if(IsPlayerConnected(playa))
			{
			  if(playa != INVALID_PLAYER_ID)
			  {
					if (ProxDetectorS(8.0, playerid, playa))
					{
					  /*new Float:gzx, Float:gzy, Float:gzz; GetPlayerPos(playerid,gzx,gzy,gzz);
					  for(new zone = 0; zone < MAX_ZONES; zone++)
					  {
						if(gzx >= ZoneLocations[zone][0] && gzx < ZoneLocations[zone][2] && gzy >= ZoneLocations[zone][1] && gzy < ZoneLocations[zone][3])
				    {
				      if(ZoneInfo[zone][ZoneOwnerID] == PlayerInfo[playerid][pFaction]) // falls der Dealer = GebietBesitzer
				      {*/
					      if(playa != playerid)
					      {
						      	format(string, sizeof(string), "[INFO:] Du hast %s %d Gramm Gras vertickt.", GetPlayerNameEx(playa), needed);
						      	SendClientMessage(playerid, COLOR_LIGHTYELLOW2, string);

						      	format(string, sizeof(string), "[INFO:] %s hat dir %d Gramm Gras.", GetPlayerNameEx(playerid), needed);
						      	SendClientMessage(playa, COLOR_LIGHTYELLOW2, string);

						      	PlayerInfo[playa][pGras] += needed;
						      	PlayerInfo[playerid][pGras] -= needed;
						      	PlayerPlayerActionMessage(playerid,playa,15.0,"ьbergibt ein Tьtchen mit Gras an");
						    }
						    else
						    {
						      SendClientMessage(playerid, COLOR_LIGHTRED, "[ERROR:] Du kannst dir selber kein Gras verticken!");
						    }
						/*	}
					    else
					    {
					  		SendClientMessage(playerid, COLOR_LIGHTRED, "[ERROR:] Du bist nicht in deinem Viertel!");
							}
						}
						}*/
					}
					else
					{
					  SendClientMessage(playerid, COLOR_LIGHTRED, "[ERROR:] Diese Spieler ist zu weit entfernt!");
					}
				}
			}
			else
			{
			  SendClientMessage(playerid, COLOR_LIGHTRED, "[ERROR:] Ungьltige ID.");
			}
		}
		return 1;
	}
The second try ist in a comment .. you can see it ..
Reply
#2

Translate the command to english
Reply
#3

My English isn't cery good ^^

Код:
	if(strcmp(cmd, "/dealen", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_LIGHTBLUE, "[USAGE:] /dealen [PlayerID/Name] [Amount]");
				return 1;
			}
			
			new Float:gzx, Float:gzy, Float:gzz; GetPlayerPos(playerid,gzx,gzy,gzz);
			for(new zone = 0; zone < MAX_ZONES; zone++)
			{
				if(gzx >= ZoneLocations[zone][0] && gzx < ZoneLocations[zone][2] && gzy >= ZoneLocations[zone][1] && gzy < ZoneLocations[zone][3])
				{
				  if(ZoneInfo[zone][ZoneOwnerID] != PlayerInfo[playerid][pFaction]) // if Dealer != ZoneOwner
				  {
						SendClientMessage(playerid, COLOR_LIGHTRED, "[ERROR:] You are not in your Zone!");
						return 1;
					}
				}
			}

			new playa;
			new needed;
			playa = ReturnUser(tmp);

			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
			  return 1;
			}

			needed = strval(tmp);
			if(needed < 1 || needed > 10)
			{
			  SendClientMessage(playerid, COLOR_LIGHTRED, "[ERROR:] Max Amount is 10g");
			  return 1;
			}

			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
			  return 1;
			}
			
			if(needed > PlayerInfo[playerid][pGras])
			{
			  SendClientMessage(playerid, COLOR_LIGHTRED, "[ERROR:] You don't have so much!");
			  return 1;
			}
			
			if(IsPlayerConnected(playa))
			{
			  if(playa != INVALID_PLAYER_ID)
			  {
					if (ProxDetectorS(8.0, playerid, playa))
					{
					  /*new Float:gzx, Float:gzy, Float:gzz; GetPlayerPos(playerid,gzx,gzy,gzz);
					  for(new zone = 0; zone < MAX_ZONES; zone++)
					  {
						if(gzx >= ZoneLocations[zone][0] && gzx < ZoneLocations[zone][2] && gzy >= ZoneLocations[zone][1] && gzy < ZoneLocations[zone][3])
				    {
				      if(ZoneInfo[zone][ZoneOwnerID] == PlayerInfo[playerid][pFaction]) // if Dealer != ZoneOwner
				      {*/
					      if(playa != playerid)
					      {
						      	format(string, sizeof(string), "[INFO:] You have sold %s %d g Weed ", GetPlayerNameEx(playa), needed);
						      	SendClientMessage(playerid, COLOR_LIGHTYELLOW2, string);

						      	format(string, sizeof(string), "[INFO:] %s has sold you %d g Weed.", GetPlayerNameEx(playerid), needed);
						      	SendClientMessage(playa, COLOR_LIGHTYELLOW2, string);

						      	PlayerInfo[playa][pGras] += needed;
						      	PlayerInfo[playerid][pGras] -= needed;
						      	PlayerPlayerActionMessage(playerid,playa,15.0,"give Weed to");
						    }
						    else
						    {
						      SendClientMessage(playerid, COLOR_LIGHTRED, "[ERROR:] You can't sell Weed to yourself!");
						    }
						/*	}
					    else
					    {
					  		SendClientMessage(playerid, COLOR_LIGHTRED, "[ERROR:] You are not in your own Zone!");
							}
						}
						}*/
					}
					else
					{
					  SendClientMessage(playerid, COLOR_LIGHTRED, "[ERROR:] This player isn't near enough!");
					}
				}
			}
			else
			{
			  SendClientMessage(playerid, COLOR_LIGHTRED, "[ERROR:] False ID.");
			}
		}
		return 1;
	}
Reply
#4

Hmm, highlight your zones with gangzones, try again, but maybe array order isn't correct, i don't know, and FAIL for meh, i didn't understand anything of that german writings....
Reply
#5

Quote:
Originally Posted by RSX
i didn't understand anything of that german writings....
translated to english ... look over your post ^^
Reply
#6

Yea, then you could do what i said, and say, is there's problem, or zones are correct...
Reply
#7

Do you mean, i should make "GangZoneCreate" ? Is it that? - This is already done.

I am standing in my own Zone ... I can defend it in a gangwar ... but when I try to sell drugs .. nothing happens ...
Reply
#8

Can sb. help? This is a simpel if clause which every pro should know
Reply
#9

I'm not the best scripter, but only mistake i found was :
Код:
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
			  return 1;
			}
I think maybe you are asking for comand to be with /dealen [player] [count] [pointless 3rd varibale, witch is required]?
Have you tested, what happens when you aren't in your zone, does messages works?
Reply
#10

No, he doesn't .. what should I change?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)