SA-MP Forums Archive
Control system - 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: Control system (/showthread.php?tid=631260)



Control system - silverms - 26.03.2017

hey so is there a way to make the player control player I have this system but it isn't workin
:
PHP код:
CMD:pmhcontrol(playerid, params[])
{
    if(
adlvl(playerid)<3) return 0;
    new 
pid;
    if(
sscanf(params,"i",pid)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /control [playerid]");
    
TogglePlayerSpectating(playerid, 1);
    
PlayerSpectatePlayer(playerid, pid);
    
SendClientMessage(playerid, 0xFF0000FF, "Control the player using W,S,A,D!");
    
CallLocalFunction("lel", "dd", playerid, pid);
    
SetTimerEx("lel", 1, true, "i", playerid);
    
SetPlayerFacingAngle(pid, 0);
    
control[playerid] = 1;
    return 
1;
}
public 
lel(playerid, id)
{
    if(
control[playerid] == 1) {
    new 
Keys,ud,lr;
    
GetPlayerKeys(playerid,Keys,ud,lr);
    if(
ud == KEY_UP) return SetPlayerVelocity(id, 0.2, 0.0, 0.0);
    else if(
ud == KEY_DOWN) return SetPlayerVelocity(id, -0.2, 0.0, 0.0);
    if(
lr == KEY_LEFT) return SetPlayerVelocity(id, 0.0, 0.2, 0.0);
    else if(
lr == KEY_RIGHT) return SetPlayerVelocity(id, 0.0, -0.2, 0.0); }
    return 
1;
} 



Re: Control system - J0sh... - 26.03.2017

You should do that with
PHP код:
public OnPlayerUpdate(playerid) 
and not a timer.


Re: Control system - silverms - 26.03.2017

thanks