SA-MP Forums Archive
Disable player keys - 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: Disable player keys (/showthread.php?tid=230895)



Disable player keys - sim_sima - 24.02.2011

Hi guys. I made a /goafk command. I want to disable the player keys when he is afk, so the only thing he can do is typing in chat. How can i do that?

Her is what i already made:
pawn Код:
if (strcmp("/goafk", cmdtext, true, 10) == 0)
    {
        currentvw = GetPlayerVirtualWorld(playerid);
        currentcolor = GetPlayerColor(playerid);
        SetPlayerColor(playerid, COLOR_GREY);
        SetPlayerVirtualWorld(playerid, 5);
        return 1;
    }
   
    if (strcmp("/back", cmdtext, true, 10) == 0)
    {
        SetPlayerColor(playerid, currentcolor);
        SetPlayerVirtualWorld(playerid, currentvw);
        return 1;
    }
And when you type /back, keys will be enabled again.
And i added:
pawn Код:
new currentvw;
new currentcolor;
above.

Hope someone can help me. Thank you.


Re: Disable player keys - Libra_PL - 24.02.2011

Add TogglePlayerControllable to your script. It would be like this:

Код:
if (strcmp("/goafk", cmdtext, true, 10) == 0)
    {
        currentvw = GetPlayerVirtualWorld(playerid);
        currentcolor = GetPlayerColor(playerid);
        SetPlayerColor(playerid, COLOR_GREY);
        SetPlayerVirtualWorld(playerid, 5);
        TogglePlayerControllable(playerid,1);
        return 1;
    }
    
    if (strcmp("/back", cmdtext, true, 10) == 0)
    {
        SetPlayerColor(playerid, currentcolor);
        SetPlayerVirtualWorld(playerid, currentvw);
        TogglePlayerControllable(playerid,0)
        return 1;
    }



Re: Disable player keys - sim_sima - 24.02.2011

Quote:
Originally Posted by Libra_PL
Посмотреть сообщение
Add TogglePlayerControllable to your script. It would be like this:

Код:
if (strcmp("/goafk", cmdtext, true, 10) == 0)
    {
        currentvw = GetPlayerVirtualWorld(playerid);
        currentcolor = GetPlayerColor(playerid);
        SetPlayerColor(playerid, COLOR_GREY);
        SetPlayerVirtualWorld(playerid, 5);
        TogglePlayerControllable(playerid,1);
        return 1;
    }
    
    if (strcmp("/back", cmdtext, true, 10) == 0)
    {
        SetPlayerColor(playerid, currentcolor);
        SetPlayerVirtualWorld(playerid, currentvw);
        TogglePlayerControllable(playerid,0)
        return 1;
    }
Thank you man! I love you!


Re: Disable player keys - deather - 24.02.2011

TogglePlayerControllable(playerid, false); This will freeze the player so that his keys gets disabled. But he can chat.

TogglePlayerControllable(playerid, true); This will unfreeze the player so that his keys gets enabled.

More info? TogglePlayerControllable


Re: Disable player keys - sim_sima - 24.02.2011

Quote:
Originally Posted by deather
Посмотреть сообщение
TogglePlayerControllable(playerid, false); This will freeze the player so that his keys gets disabled. But he can chat.

TogglePlayerControllable(playerid, true); This will unfreeze the player so that his keys gets enabled.

More info? TogglePlayerControllable
Thank you very much!