Behind player? - 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: Behind player? (
/showthread.php?tid=498166)
Behind player? -
Lajko1 - 02.03.2014
How to change this code to get position behind player?
It's for /cuff command
pawn Код:
stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
new Float:a;
GetPlayerPos(playerid, x, y, a);
GetPlayerFacingAngle(playerid, a);
if (GetPlayerVehicleID(playerid))
{
GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
}
//a +=0;//misschien niet bodig
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
}
Re: Behind player? -
Pottus - 02.03.2014
pawn Код:
stock GetXYInBehindOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
new Float:a;
GetPlayerPos(playerid, x, y, a);
GetPlayerFacingAngle(playerid, a);
if (GetPlayerVehicleID(playerid))
{
GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
}
a -= 180.0;
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
}
Re: Behind player? -
Lajko1 - 02.03.2014
if(GetXYInBehindOfPlayer(playerid,i,0.5,0.5))
Errors:
warning 213: tag mismatch
error 035: argument type mismatch (argument 3)
Re: Behind player? -
Lajko1 - 02.03.2014
Actually my bad I forgot to post that also
pawn Код:
stock IsPlayerInFrontOfPlayer(playerid,targetid,Float:distance,Float:range)
{
if(!IsPlayerConnected(playerid) || !IsPlayerConnected(targetid))return 0;
{
new Float:x, Float:y, Float:z;
GetPlayerPos(targetid,x, y, z);//my pos
GetXYInFrontOfPlayer(targetid,x,y,distance);
if(IsPlayerInRangeOfPoint(playerid,range,x,y,z))return 1;
}
return 0;
}
When I changed
pawn Код:
if(GetXYInFrontOfPlayer(playerid,i,0.5,0.5))
to
pawn Код:
if(GetXYInFrontOfPlayer(playerid,i,0.5,0.5))
I received those errors
pawn Код:
warning 213: tag mismatch
error 035: argument type mismatch (argument 3)
and cmd is:
pawn Код:
if(!strcmp(cmdtext, "/cuff", true))
{
if(sendername[0] == '[' && sendername[1] == 'P' && sendername[2] == 'D' && sendername[3] == ']' || GetPlayerSkin(playerid) == 71)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(i!=playerid)
{
if(GetXYInBehindOfPlayer(playerid,i,0.5,0.5)) // error line
{
SendClientMessage(playerid,COLOR_RED,"You cuffed a suspect");
SetPlayerSpecialAction(i,SPECIAL_ACTION_CUFFED);
SetPlayerAttachedObject(i,6,19418,6,-0.000999,0.038999,-0.016000,162.300003,-169.399963,-76.699989,0.855000,1.412998,1.711999);
GameTextForPlayer(i,"~r~BUSTED!!",3000,5);
}
}
}
}
else
{
SendClientMessage(playerid,COLOR_RED,"You are not authorized to use this command!");
return 1;
}
return 1;
}