SA-MP Forums Archive
command help - 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: command help (/showthread.php?tid=88014)



command help - WardenCS - 23.07.2009

hello,i got one cmd,and i want to make it like i can use it only if im at some coordinates,
338.4752,-2416.0164,14.2604
thanks


Re: command help - mprofitt - 23.07.2009

Код:
dcmd_shpos(playerid, params[])
{
	new string[128];
	new Float:x, Float:y, Float:z, Float:a;
	GetPlayerPos(playerid, x, y, z);
	GetPlayerFacingAngle(playerid,a);
	format(string, sizeof(string), "X=%f  Y=%f  Z=%f  A=%f",x,y,z,a);
	SendClientMessage(playerid, COLOR_RED, string);
	#pragma unused params
	return 1;
}



Re: command help - WardenCS - 23.07.2009

where do i add coordinates and where i add those lines?


Re: command help - MadeMan - 23.07.2009

You can use PlayerToPoint

pawn Код:
if(PlayerToPoint(1.0, playerid, 338.4752,-2416.0164,14.2604))
You need this somewhere in your script:

pawn Код:
stock PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
    if(IsPlayerConnected(playerid))
    {
        new Float:oldposx, Float:oldposy, Float:oldposz;
        new Float:tempposx, Float:tempposy, Float:tempposz;
        GetPlayerPos(playerid, oldposx, oldposy, oldposz);
        tempposx = (oldposx -x);
        tempposy = (oldposy -y);
        tempposz = (oldposz -z);
        if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
        {
            return 1;
        }
    }
    return 0;
}