SA-MP Forums Archive
Help me to complete a 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)
+--- Thread: Help me to complete a command! (/showthread.php?tid=398984)



Help me to complete a command! - Laure - 12.12.2012

Ok here i tried to make a command which shows me the Businesses id and owner of the biz within 2 meters of me but it is not working at all.Codes Below
Код:
CMD:nearbiz(playerid, params[])
{
	new idx, string[128];
    if(PlayerInfo[playerid][pAdmin] < 1337) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command");
	{
		SendClientMessage(playerid, COLOR_LIGHTGREEN, "* All businesses in the range of 2 meters of you.");
		new Float:X, Float:Y, Float:Z;
		new Float:X2, Float:Y2, Float:Z2;
  		GetPlayerPos(playerid, X2, Y2, Z2);
		for(new i;i<MAX_BIZ;i++)
		{
			if(IsPlayerInRangeOfPoint(playerid, 2, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]))
			{
				    new string[128];
			    	format(string, sizeof(string), "Business ID: %d | Owned by: %s", idx, BizInfo[idx][bOwner]);
			    	SendClientMessage(playerid, COLOR_WHITE, string);
			}
		}
	}
	return 1;
}
Help will be appreciated!


Re: Help me to complete a command! - David (Sabljak) - 12.12.2012

if(!IsPlayerInRangeOfPoint(playerid, 2, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]))

try with "!"


Re: Help me to complete a command! - Threshold - 12.12.2012

pawn Код:
CMD:nearbiz(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 1337) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command");
    SendClientMessage(playerid, COLOR_LIGHTGREEN, "* All businesses in the range of 2 meters of you.");
    new Count = 0;
    new Float:X, Float:Y, Float:Z;
    new Float:X2, Float:Y2, Float:Z2;
    GetPlayerPos(playerid, X2, Y2, Z2);
    for(new i; i < MAX_BIZ; i++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 2, BizInfo[i][bX], BizInfo[i][bY], BizInfo[i][bZ]))
        {
            new string[128];
            Count++;
            format(string, sizeof(string), "Business ID: %d | Owned by: %s", i, BizInfo[i][bOwner]);
            SendClientMessage(playerid, COLOR_WHITE, string);
        }
        else continue;
    }
    if(Count == 0)
    {
        SendClientMessage(playerid, COLOR_RED, "You are not close to any businesses at the moment.");
    }
    return 1;
}
EDIT: Added 'No businesses nearby' message.


Re: Help me to complete a command! - Laure - 12.12.2012

Thank you very much Benzo you deserve a rep