cuff 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)
+--- Thread: cuff help (
/showthread.php?tid=362734)
cuff help -
jimis - 25.07.2012
Hi guys i have an arrest system without cuff.So,i want when a cop press 'N' then the nearst player will be not be able to move,how i can do that?
Thanks
Re: cuff help -
Kindred - 25.07.2012
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if((newkeys & KEY_NO) && !(oldkeys & KEY_NO))//If player presses N (Key no)
{
if(CopVariable[playerid] = certainvalue)
{
TogglePlayerControllable(GetClosestPlayerToPlayer(playerid),0);
}
}
return 1;
}
forward GetClosestPlayerToPlayer(playerid);
public GetClosestPlayerToPlayer(playerid)
{
new Float:dist = 1000.0;
new targetid = INVALID_PLAYER_ID;
new Float:x1,Float:y1,Float:z1;
new Float:x2,Float:y2,Float:z2;
new Float:tmpdis;
GetPlayerPos(playerid,x1,y1,z1);
for(new i=0;i<MAX_PLAYERS;i++)
{
if(i == playerid) continue;
GetPlayerPos(i,x2,y2,z2);
tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
if(tmpdis < dist)
{
dist = tmpdis;
targetid = i;
}
}
return targetid;
}
Try something similar to this.
Of course you HAVE to change the adminvariable, considering it was just an example, then the value you want them to be to use it.
Re: cuff help -
jimis - 25.07.2012
Ok,thanks,but how i can check if other player is suspect?
Re: cuff help -
Kindred - 25.07.2012
Show us your suspect variable.
Or use GetPlayerWantedLevel.
Re: cuff help -
jimis - 25.07.2012
ok but where to set getplayerwantedleveL?
Re: cuff help -
Kindred - 25.07.2012
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if((newkeys & KEY_NO) && !(oldkeys & KEY_NO))//If player presses N (Key no)
{
if(CopVariable[playerid] = certainvalue)
{
if(GetPlayerWantedLevel(playerid) >= 1)
{
TogglePlayerControllable(GetClosestPlayerToPlayer(playerid),0);
}
}
}
return 1;
}
Seriously, why doesn't anyone learn basic coding before asking questions?