[Help]Handcuff on Key(Filescript)
#1

Hi everyone. Who can help me with Handcuff i make freeroam server but I do in my server jobs and i have police officer job so i want to handcuff script on key. http://pastebin.com/zRiY0m37 i try this filescript(I do on key"Numpad 6") but when i click write you cannot cuff yourself.
So. edit this script so can I cuff People
Please help.
Reply
#2

So You cannot help ?
Reply
#3

I think nobody will help you with this filterscript because you will claim the filterscript.
Reply
#4

I don't need to make filescript. I need to edit you OnPlayerKeyState I new in this...
Reply
#5

Well the wiki (https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange) has a good amount of information on key detecting.

To sum up the wiki, use the following defines:
pawn Код:
// HOLDING(keys)
#define HOLDING(%0) \
    ((newkeys & (%0)) == (%0))

// PRESSED(keys)
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

// RELEASED(keys)
#define RELEASED(%0) \
    (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
Then look at the examples on how they are used:

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (PRESSED(KEY_FIRE))
    {
        if (IsPlayerInAnyVehicle(playerid))
        {
            AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
        }
    }
    return 1;
}
To know what keys you can use:
https://sampwiki.blast.hk/wiki/GetPlayerKeys


Remember, you cant say the 'R' key, but instead the Conversation_Yes key for example, that by Default is Y, but people can change their games key settings to use R instead of Y.
Reply
#6

I try but that not working if you edit i Understand that. Without not need //
pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT

#include <a_samp>
#include zcmd
#include sscanf
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Handcuff System by Tee           ");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}
#endif


public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_ANALOG_RIGHT, newkeys, oldkeys))
        {
   
    new id,Cuff[MAX_PLAYERS],Name[MAX_PLAYER_NAME],string[MAX_PLAYERS],pskin = GetPlayerSkin(playerid);
    for (new i=0; i<MAX_PLAYERS; i++){
    if(pskin == 265 || pskin == 266 || pskin == 267 || pskin == 280 || pskin == 281 || pskin == 284 || pskin == 285 || pskin == 286 || pskin == 287 || pskin == 288){
    if(id == playerid)return SendClientMessage(playerid,0xC0C0C0FF,"**You cannot cuff yourself.");
    if(GetDistanceBetweenPlayers(playerid,id)> 2)return SendClientMessage(playerid,0xC0C0C0FF,"You are to far from that player");
    }else return SendClientMessage(playerid,0xC0C0C0FF,"You dont have permisson to access this command.");
    {
    SetPlayerSpecialAction(playerid, SPECIAL_ACTION_CUFFED );// zaidejo animacija[Rankos uz nugaros]  
    SetPlayerAttachedObject(playerid,0,19418,5,0.016000,0.032000,0.025000,17.500005,-10.099991,-48.099990,1.0,1.0,1.0 );//Zaidejui uzdedami antrankiai
    TogglePlayerControllable(id,false);
    }
    {
    GetPlayerName(playerid, Name, sizeof(Name));
    format(string, sizeof(string), "You have been restrained in handcuffs by %s.",Name);
    }SendClientMessage(i,0xFF0000FF,string);
    }
    Cuff[id] = 1;
    return 1;
}

    if(PRESSED(KEY_ANALOG_LEFT, newkeys, oldkeys))
{
    new id,Cuff[MAX_PLAYERS],Name[MAX_PLAYER_NAME],string[MAX_PLAYERS],pskin = GetPlayerSkin(playerid);
    for (new i=0; i<MAX_PLAYERS; i++){
    if(pskin == 265 || pskin == 266 || pskin == 267 || pskin == 280 || pskin == 281 || pskin == 284 || pskin == 285 || pskin == 286 || pskin == 287 || pskin == 288){
    if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0xC0C0C0FF,"**You can't uncuff someone from a vehicle.");
    if(id == playerid)return SendClientMessage(playerid,0xC0C0C0FF,"**You cannot uncuff yourself.");
    if(GetDistanceBetweenPlayers(playerid,id)> 2)return SendClientMessage(playerid,0xC0C0C0FF,"You are to far from that player");
    }else return SendClientMessage(playerid,0xC0C0C0FF,"You dont have permisson to access this command.");
    {
    RemovePlayerAttachedObject(playerid,0); //Panaikina antrankius
    SetPlayerSpecialAction(playerid,SPECIAL_ACTION_NONE);// Nustato ,kad nebutu
    TogglePlayerControllable(id,true);
    }
    {
    GetPlayerName(playerid, Name, sizeof(Name));
    format(string, sizeof(string), "Your handcuffs have been removed by %s.",Name);
    }SendClientMessage(i,0xFF0000FF,string);
    }
    Cuff[id] = 0;
    return 1;
    }
    return 1;
    }

//-------------------------------DISTANCE-------------------------------------//
stock GetDistanceBetweenPlayers(playerid,playerid2)
{
    new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
    new Float:tmpdis;
    GetPlayerPos(playerid,x1,y1,z1);
    GetPlayerPos(playerid2,x2,y2,z2);
    tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
    return floatround(tmpdis);
}
Reply
#7

So can help ?
Reply
#8

Up. Please help
Sorry For double post
Reply
#9

don't bump
Reply
#10

Try this:

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_ANALOG_RIGHT, newkeys, oldkeys))
        {

    new id,Cuff[MAX_PLAYERS],Name[MAX_PLAYER_NAME],string[MAX_PLAYERS],pskin = GetPlayerSkin(playerid);
	for (new i=0; i<MAX_PLAYERS; i++)
	{
	    new Float:x, Float:y, Float:z;
	    GetPlayerPos(playerid, x, y, z);
	    
	    if(IsPlayerInRangeOfPoint(i, 5, x, y, z) && i != playerid)
	    {
	        id = i;
	    }
	}
	for (new i=0; i<MAX_PLAYERS; i++){
    if(pskin == 265 || pskin == 266 || pskin == 267 || pskin == 280 || pskin == 281 || pskin == 284 || pskin == 285 || pskin == 286 || pskin == 287 || pskin == 288){
    if(id == playerid)return SendClientMessage(playerid,0xC0C0C0FF,"**You cannot cuff yourself.");
    if(GetDistanceBetweenPlayers(playerid,id)> 2)return SendClientMessage(playerid,0xC0C0C0FF,"You are to far from that player");
    }else return SendClientMessage(playerid,0xC0C0C0FF,"You dont have permisson to access this command.");
    {
    SetPlayerSpecialAction(playerid, SPECIAL_ACTION_CUFFED );// zaidejo animacija[Rankos uz nugaros]
    SetPlayerAttachedObject(playerid,0,19418,5,0.016000,0.032000,0.025000,17.500005,-10.099991,-48.099990,1.0,1.0,1.0 );//Zaidejui uzdedami antrankiai
    TogglePlayerControllable(id,false);
    }
    {
    GetPlayerName(playerid, Name, sizeof(Name));
    format(string, sizeof(string), "You have been restrained in handcuffs by %s.",Name);
    }SendClientMessage(i,0xFF0000FF,string);
    }
    Cuff[id] = 1;
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)