IsPlayerInRangeOfPoint/Command problem
#4

Quote:
Originally Posted by KuHS
Simply the command checks for all houses within for() looping with returns, so it's wrong. Example: 1 house, it checks, and it's not found, it sends a message, when returns and don't check for 2 house... am i right? I suggest you to use continue; function in for() loops. In for() loops return stops looping, continue just ends variable looping.

BTW. If you want to send end message, send it before for() looping.

Код:
if(strcmp(cmd,"/kaufen",true)==0)
	{
		for(new i=0;i<MAX_HOUSES;i++)
		{
		  if(!IsPlayerInRangeOfPoint(playerid, 3.0, HausInfo[i][eX], HausInfo[i][eY], HausInfo[i][eZ])) continue;
		    if(GetPlayerMoney(playerid) < HausInfo[i][Preis])
				{
		    	new Name[MAX_PLAYER_NAME];
			    GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
					GivePlayerMoney(playerid, - HausInfo[i][Preis]);
					strmid(HausInfo[i][Besitzer], Name, 0, strlen(Name), 24);
					HausInfo[i][Vergeben] = 1;
					SendClientMessage(playerid, FARBE_WEIЯ,"Du hast das Haus gekauft, um Befehle anzusehen schreibe /hauscmds !");
					return 1;
				}
				else
				{
				  SendClientMessage(playerid,FARBE_WEIЯ,"Du hast zu wenig Geld, du musst zuerst das Geld auf der Hand haben.");
				  return 1;
			 	}
		}
		return 1;
	}
Thanks for the answer, but I have still one error,
namely from here:

Код:
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
GivePlayerMoney(playerid, - HausInfo[i][Preis]);
strmid(HausInfo[i][Besitzer], Name, 0, strlen(Name), 24);
HausInfo[i][Vergeben] = 1;
SendClientMessage(playerid, FARBE_WEIЯ,"Du hast das Haus gekauft, um Befehle anzusehen schreibe /hauscmds !");
return 1;
The 2 lines are not running:

Код:
strmid(HausInfo[i][Besitzer], Name, 0, strlen(Name), 24);
HausInfo[i][Vergeben] = 1;
Whats here the problem?
Thx
Reply


Messages In This Thread
IsPlayerInRangeOfPoint/Command problem - by wofka13 - 24.06.2010, 10:27
Re: IsPlayerInRangeOfPoint/Command problem - by bajskorv123 - 24.06.2010, 10:29
Re: IsPlayerInRangeOfPoint/Command problem - by KuHS - 24.06.2010, 10:32
Re: IsPlayerInRangeOfPoint/Command problem - by wofka13 - 24.06.2010, 15:15
Re: IsPlayerInRangeOfPoint/Command problem - by KuHS - 24.06.2010, 16:54
Re: IsPlayerInRangeOfPoint/Command problem - by wofka13 - 24.06.2010, 17:12

Forum Jump:


Users browsing this thread: 1 Guest(s)