Handcuffs
#1

I have this cuff and uncuff command but it doesnt take the cuffs off when he is uncuffed
PHP код:
CMD:cuff(playeridparams[])//This is will create you cmd so you can continue your codes.
    
{
    new 
targetid;//this defines the id of the player you want to cuff((playerid id your id and the target id that I defined it the id of the player you want to cuff))
    
if(sscanf(params"r"targetid)) return SendClientMessage(playerid, -1"[USAGE]: /cuff [Part of Name/Player ID]");
    if(
IsPlayerConnected(targetid))//this will check that if the player you want to cuff is connected to the server or not.
    
{
    new 
Float:xFloat:yFloat:z;//these are the defines of your x,y and z position.
    
GetPlayerPos(playeridxyz);//this will store your position to be used in the following codes.this stores the your x,y, and z position in to the variables we created
    
if(IsPlayerInRangeOfPoint(targetid5.0xyz))//this will check that if the player you want to cuff is near you or not.
    
{
    new 
str[50];//this it the define for the string you will format further.((str means string.You can also change it to string but this seems to be easy.))
    
new name[MAX_PLAYER_NAME];//this is the variable you created to store your name.
    
GetPlayerName(playeridnamesizeof(name));//this will get your name and store it in the variable you defines as name.
    
new target[MAX_PLAYER_NAME];//this is the variable you created to store the name of the player you want to cuff.
    
GetPlayerName(targetidtargetsizeof(target));//this will get the name of the person you want to cuff and will store it into a variable we defined as target.
    
format(strsizeof(str), "INFO: You have cuffed %s!",target);//explained at the end of the tutorial.
    
SendClientMessage(playerid0xE01B1Bstr);//this will send the formated message to you that you created before.
    
format(strsizeof(str), "WARNING: You have been cuffed by %s!",name);//explained at the end of the tutorial.
    
SendClientMessage(targetid0xE01B1Bstr);//this will send the formated message to the player you cuffed.
    
SetPlayerAttachedObject(targetid0194186, -0.0110000.028000, -0.022000, -15.600012, -33.699977,-81.7000350.8919991.0000001.168000);//this will set the object cuffs at the hand of the player you want to cuff.
    
SetPlayerSpecialAction(targetid,SPECIAL_ACTION_CUFFED);//this will set players hand backwards.
    
return 1;
    }
    }
    return 
1;
    }
    
CMD:uncuff(playeridparams[])
    {
    new 
targetid;//this defines the id of the player you want to cuff((playerid id your id and the target id that I defined it the id of the player you want to cuff))
     
if(sscanf(params"r"targetid)) return SendClientMessage(playerid, -1"[USAGE]: /uncuff [Part of Name/Player ID]");
      if(
IsPlayerConnected(targetid))//this will check that if the player you want to cuff is connected to the server or not.
       
{
    new 
Float:xFloat:yFloat:z;//these are the defines of your x,y and z position.
    
GetPlayerPos(playeridxyz);//this will store your position to be used in the following codes.((this stores the your x,y, and z position in to the variables we created.))
    
if(IsPlayerInRangeOfPoint(targetid5.0xyz))//this will check that if the player you want to cuff is near you or not.
    
{
    if(!
SetPlayerAttachedObject(targetid0194186, -0.0110000.028000, -0.022000, -15.600012, -33.699977,-81.7000350.8919991.0000001.168000))return SendClientMessage(playerid,-1,"ERROR: The player is not cuffed!");//this will check that if the player is not cuffed and you are trying to apply this cmd,this will send him a error message.
    
SetPlayerSpecialAction(targetid,SPECIAL_ACTION_NONE);//this will remove the players cuffs and his arms will go normal.
    
new str[50];//this it the define for the string you will format further.((str means string.You can also change it to string but this seems to be easy.))
    
new name[MAX_PLAYER_NAME];//this is the variable you created to store your name.
    
GetPlayerName(playeridnamesizeof(name));//this will get your name and store it in the variable you defines as name.
    
new target[MAX_PLAYER_NAME];//this is the variable you created to store the name of the player you want to cuff.
    
GetPlayerName(targetidtargetsizeof(target));//this will get the name of the person you want to cuff and will store it into a variable we defined as target.
    
format(strsizeof(str), "INFO: You have uncuffed %s!",target);//explained at the end of the tutorial.
    
SendClientMessage(playerid0xE01B1Bstr);//will send the formated message to you that you created above.
    
format(strsizeof(str), "WARNING: You have been uncuffed by %s!",name);//explained bellow.
    
SendClientMessage(targetid0xE01B1Bstr);//will send the formated message to the player you want to cuff that you created above.
    
return 1;
    }
    }
     return 
1;
    } 
Reply
#2

Instead of checking if an object is attached you should make a variable that is changed and checked instead.
Reply
#3

What you mean?
Reply
#4

Here is the new code:

pawn Код:
CMD:cuff(playerid, params[])//This is will create you cmd so you can continue your codes.
{
    new targetid;//this defines the id of the player you want to cuff((playerid id your id and the target id that I defined it the id of the player you want to cuff))
    if(sscanf(params, "r", targetid)) return SendClientMessage(playerid, -1, "[USAGE]: /cuff [Part of Name/Player ID]");
    if(IsPlayerConnected(targetid))//this will check that if the player you want to cuff is connected to the server or not.
    {
        new Float:x, Float:y, Float:z;//these are the defines of your x,y and z position.
        GetPlayerPos(playerid, x, y, z);//this will store your position to be used in the following codes.this stores the your x,y, and z position in to the variables we created
        if(IsPlayerInRangeOfPoint(targetid, 5.0, x, y, z))//this will check that if the player you want to cuff is near you or not.
        {
            new str[50];//this it the define for the string you will format further.((str means string.You can also change it to string but this seems to be easy.))
            new name[MAX_PLAYER_NAME];//this is the variable you created to store your name.
            GetPlayerName(playerid, name, sizeof(name));//this will get your name and store it in the variable you defines as name.
            new target[MAX_PLAYER_NAME];//this is the variable you created to store the name of the player you want to cuff.
            GetPlayerName(targetid, target, sizeof(target));//this will get the name of the person you want to cuff and will store it into a variable we defined as target.
            format(str, sizeof(str), "INFO: You have cuffed %s!",target);//explained at the end of the tutorial.
            SendClientMessage(playerid, 0xE01B1B, str);//this will send the formated message to you that you created before.
            format(str, sizeof(str), "WARNING: You have been cuffed by %s!",name);//explained at the end of the tutorial.
            SendClientMessage(targetid, 0xE01B1B, str);//this will send the formated message to the player you cuffed.
            SetPlayerAttachedObject(targetid, 0, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977,-81.700035, 0.891999, 1.000000, 1.168000);//this will set the object cuffs at the hand of the player you want to cuff.
            SetPlayerSpecialAction(targetid,SPECIAL_ACTION_CUFFED);//this will set players hand backwards.
            return 1;
        }
    }
    return 1;
}
   
CMD:uncuff(playerid, params[])
{
    new targetid;//this defines the id of the player you want to cuff((playerid id your id and the target id that I defined it the id of the player you want to cuff))
    if(sscanf(params, "r", targetid)) return SendClientMessage(playerid, -1, "[USAGE]: /uncuff [Part of Name/Player ID]");
    if(IsPlayerConnected(targetid))//this will check that if the player you want to cuff is connected to the server or not.
    {
        new Float:x, Float:y, Float:z;//these are the defines of your x,y and z position.
        GetPlayerPos(playerid, x, y, z);//this will store your position to be used in the following codes.((this stores the your x,y, and z position in to the variables we created.))
        if(IsPlayerInRangeOfPoint(targetid, 5.0, x, y, z))//this will check that if the player you want to cuff is near you or not.
        {
            if(!SetPlayerAttachedObject(targetid, 0, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977,-81.700035, 0.891999, 1.000000, 1.168000))return SendClientMessage(playerid,-1,"ERROR: The player is not cuffed!");//this will check that if the player is not cuffed and you are trying to apply this cmd,this will send him a error message.
            SetPlayerSpecialAction(targetid,SPECIAL_ACTION_NONE);//this will remove the players cuffs and his arms will go normal.
            RemovePlayerAttachedObject(targetid, 0); // This will remove the cuff object!
            new str[50];//this it the define for the string you will format further.((str means string.You can also change it to string but this seems to be easy.))
            new name[MAX_PLAYER_NAME];//this is the variable you created to store your name.
            GetPlayerName(playerid, name, sizeof(name));//this will get your name and store it in the variable you defines as name.
            new target[MAX_PLAYER_NAME];//this is the variable you created to store the name of the player you want to cuff.
            GetPlayerName(targetid, target, sizeof(target));//this will get the name of the person you want to cuff and will store it into a variable we defined as target.
            format(str, sizeof(str), "INFO: You have uncuffed %s!",target);//explained at the end of the tutorial.
            SendClientMessage(playerid, 0xE01B1B, str);//will send the formated message to you that you created above.
            format(str, sizeof(str), "WARNING: You have been uncuffed by %s!",name);//explained bellow.
            SendClientMessage(targetid, 0xE01B1B, str);//will send the formated message to the player you want to cuff that you created above.
            return 1;
        }
    }
    return 1;
}
The added line is this one:
pawn Код:
RemovePlayerAttachedObject(targetid, 0);
Reply
#5

Quote:
Originally Posted by lramos15
Посмотреть сообщение
What you mean?
When you're checking if the player is cuffed, you're checking if the handcuff object is attached to the player. Would it not be better practice to set a variable like... PlayerInfo[playerid][pCuffed] or something similar?
Reply
#6

It took me hours to write this I cant do that.
Reply
#7

If you can't do that then your script is going to be severely limited, and probably slow and buggy.
Reply
#8

this is the basic idea:
BASIC IDEA!
PHP код:

enum listOfVars 
{
username,
level,
BOOL:cuffed
}
#define pInfo[MAX_PLAYERS]listOfVars;
CMD:cuffe(...){
if (!
pInfo[playerid]cuffed) {
// cuffe here
pInfo[playerid]cuffed =  1;
}
}
CMD:uncuffe(...){
if (
pInfo[playerid]cuffed != 0) {
// uncuffe here
pInfo[playerid]cuffed =  0;
}

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)