ZCMD - Help
#1

Hello,
i want to know how can i use COMMAND:arrest(playerid, params[]) under OnPlayerKeyState...

is there any way?
or any code? to perform the command under onplayerkeystate?
Reply
#2

Yes, you gave the answer yourself already:

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == Whatever key)
    {
        new closestplayer =  //Get The Closest player
        new target[4];
        format(target, 4, "%d", closestplayer);
        cmd_arrest(playerid, target);
    }
    return 1;
}
Reply
#3

This is an example:

A stock:
PHP код:
stock 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(
== 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;

Under OnPlayerKeyState
PHP код:
if(newkeys==a)
{
    if(
GetPlayerTeam(playerid)!=TEAM_LAW) return SendClientMessage(playeridCOLOR_RED"ERROR: You are not a law enforcement agent.");
    
CallLocalFunction("OnPlayerCommandText""is"GetClosestPlayerToPlayer(playerid), "/arrest");
    return 
1;

Reply
#4

only for playerid?
how can i call only for playerid?
Reply
#5

It Will work for the Closest Player, If you Use What ATOggy Said..
Reply
#6

but i want to use only for playerid
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)