Remove <id>
#1

is there any solution to make it just type /cuff ?i still trying it,but not working

Код:
COMMAND:cuff(playerid, params[])
{
	if(playerData[playerid][playerLoggedIn])
	{
  	    if(playerData[playerid][playerClass] == CLASS_POLICE || playerData[playerid][playerClass] == CLASS_ARMY || playerData[playerid][playerClass] == CLASS_CIA || playerData[playerid][playerClass] == CLASS_FBI || playerData[playerid][playerClass] == CLASS_SECRETSERVICE)
  	    {
            // Command for police to cuff
            new otherPlayer, cuffedBy[24], Name[24], pCuff[250], lCuff[250];
            if(sscanf(params, "u", otherPlayer))
            {
                // Invalid command syntax
                SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}Usage: \"cuff <playerID>\"");
            }
            else
            {
				if(IsPlayerConnected(otherPlayer))
				{
					if(playerData[otherPlayer][playerLoggedIn])
					{
						if(playerData[otherPlayer][playerClass] == CLASS_CIVILIAN || playerData[otherPlayer][playerClass] == CLASS_MEDIC)
						{
							// Check if the other player has a wanted level
							if(playerData[otherPlayer][playerWantedLevel] >= 6)
							{
								// Check if the player is in jail
								if (playerData[playerid][playerJailTime] == 0 && playerData[otherPlayer][playerJailTime] == 0)
								{
									if(isPlayerInRangeOfPlayer(playerid, otherPlayer, 4.0))
									{
										// If the player is not performing administrative duties
										if (!playerData[otherPlayer][playerAdminDuty])
										{
											// If OTHER player is in a vehicle
											if(!IsPlayerInAnyVehicle(otherPlayer))
											{
												// If POLICEMAN is in a vehicle
												if(!IsPlayerInAnyVehicle(playerid))
												{
													// Check if the player is already cuffed
													if(!playerData[otherPlayer][playerIsCuffed])
													{
														// Check if the player can cuff someone
														if(playerData[playerid][playerCanCuff])
														{
															if(!playerData[playerid][playerIsTied])
															{
																ClearAnimations(otherPlayer);

																GetPlayerName(playerid, cuffedBy, sizeof(Name));
																GetPlayerName(otherPlayer, Name, sizeof(Name));

																// Cuff player
																format(pCuff, sizeof(pCuff), "{FFDC2E}[CUFFED] {FFFFFF}You have been cuffed by %s(%i)", cuffedBy, playerid);
																SendClientMessage(otherPlayer, COLOR_WHITE, pCuff);

																format(lCuff, sizeof(lCuff), "{FFDC2E}[CUFFED] {FFFFFF}You have placed cuffs on %s(%i)", Name, otherPlayer);
																SendClientMessage(playerid, COLOR_WHITE, lCuff);

																SetPlayerSpecialAction(otherPlayer, SPECIAL_ACTION_CUFFED);

																// Set timer to expire and uncuff player (10 seconds)
																playerData[otherPlayer][uncuffTimer] = SetTimerEx("uncuff", 60000, false, "i", otherPlayer);
																playerData[playerid][recuffTimer] = SetTimerEx("recuff", 5000, false, "i", playerid);

																// Police cannot cuff for 5 seconds
																playerData[playerid][playerCanCuff] = false;

																// Set the otherPlayer's isCuffed to 1
																playerData[otherPlayer][playerIsCuffed] = true;

																if (playerData[otherPlayer][playerIsTied])
																{
																	playerData[otherPlayer][playerIsTied] = false;
																	KillTimer(playerData[otherPlayer][untieTimer]);
																}
															}
															else
															{
																SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You cannot do this whilst tied.");
															}
														}
														else
														{
															// Cannot cuff again yet...
															SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}Please wait before cuffing a player again.");
														}
													}
													else
													{
														// The player is already cuffed
														SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}That player is already cuffed.");
													}
												}
												else
												{
													// Player is in vehicle
													SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You cannot cuff people while you are in a vehicle.");
												}
											}
											else
											{
												// Other player is in a vehicle
												SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}The player you're trying to cuff is in a vehicle.");
											}
										}
										else
										{
											// Cannot cuff an admin on duty
											SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}That player is currently performing admin duties and cannot be cuffed!");
										}
									}
									else
									{
										// Not in range of player
										SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You are not close enough to that player.");
									}
								}
								else
								{
									// Player is in jail
									SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You cannot cuff people when they're jailed or when you are jailed.");
								}
							}
							else
							{
								SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}This player does not have a high enough wanted level.");
							}
						}
						else
						{
							// Cannot cuff a cop/cia/fbi
							SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You cannot cuff law enforcement players.");
						}
					}
					else
					{
						// Cannot cuff players who are not logged in.
						SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You cannot cuff players who are not logged in.");
					}
				}
				else
				{
					// Cannot cuff players who are not connected.
					SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}That player is not connected.");
				}
            }
        }
        else
        {
            // Player is not police
            SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}This command can only be used by the LEO classes.");
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You must be logged in to use commands.");
    }

    return 1;
}
Reply
#2

Код:
CMD:cuff(playerid, params[])
{ 
    new targetid;
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, -1, "[USAGE]: /cuff [Part of Name/Player ID]"); 
    if(IsPlayerConnected(targetid))
        { 
            new Float:x, Float:y, Float:z;
               GetPlayerPos(playerid, x, y, z);
               if(IsPlayerInRangeOfPoint(targetid, 5.0, x, y, z))
                   { 
                    new str[512];
                      new name[MAX_PLAYER_NAME];
                    GetPlayerName(playerid, name, sizeof(name)); 
                    new target[MAX_PLAYER_NAME];
                       GetPlayerName(targetid, target, sizeof(target));
                       format(str, sizeof(str), "INFO: You have cuffed %s!",target);
                       SendClientMessage(playerid, 0xE01B1B, str);
                       format(str, sizeof(str), "WARNING: You have been cuffed by %s!",name);
                       SendClientMessage(targetid, 0xE01B1B, str);
                    SetPlayerAttachedObject(targetid, 0, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977,-81.700035, 0.891999, 1.000000, 1.168000);
                      SetPlayerSpecialAction(targetid,SPECIAL_ACTION_CUFFED);
                      return 1; 
                } 

        } 
    return 1; 
}
Use this command.
Reply
#3

Try this:
pawn Код:
COMMAND:cuff(playerid, params[])
{
    if(!playerData[playerid][playerLoggedIn]) return SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You must be logged in to use commands.");
    {
        switch(playerData[playerid][playerClass])
        {
            case CLASS_POLICE, CLASS_ARMY, CLASS_CIA, CLASS_FBI, CLASS_SECRETSERVICE:
            {
                if(playerData[playerid][playerJailTime])
                    return SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You cannot cuff people when you are jailed.");
                   
                new targetid;
                if(sscanf(params, "u", targetid))
                {
                    targetid = GetClosestSuspect(playerid, 6);
                    if(targetid == INVALID_PLAYER_ID || !IsPlayerConnected(targetid))
                        return SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You are not close enough to a suspect.");
                }
                else if(targetid == INVALID_PLAYER_ID || !IsPlayerConnected(targetid))
                    return SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}That player is not connected.");

                if(!playerData[targetid][playerLoggedIn])
                    return SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You cannot cuff players who are not logged in.");
                   
                if(playerData[targetid][playerClass] != CLASS_CIVILIAN && playerData[targetid][playerClass] != CLASS_MEDIC)
                    return SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You cannot cuff law enforcement players.");

                if(playerData[targetid][playerWantedLevel] < 6)
                    return SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}This player does not have a high enough wanted level.");

                if(playerData[targetid][playerJailTime])
                    return SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You cannot cuff people when they're jailed.");

                if(!isPlayerInRangeOfPlayer(playerid, targetid, 4.0))
                    return SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You are not close enough to that player.");

                if(playerData[targetid][playerAdminDuty])
                    return SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}That player is currently performing admin duties and cannot be cuffed!");
                   
                if(IsPlayerInAnyVehicle(targetid))
                    return SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}The player you're trying to cuff is in a vehicle.");

                if(IsPlayerInAnyVehicle(playerid))
                    return SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You cannot cuff people while you are in a vehicle.");
                   
                if(playerData[targetid][playerIsCuffed])
                    return SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}That player is already cuffed.");

                if(!playerData[playerid][playerCanCuff])
                    return SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}Please wait before cuffing a player again.");

                if(playerData[playerid][playerIsTied])
                    return SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You cannot do this whilst tied.");

                ClearAnimations(targetid);
                new Name[MAX_PLAYER_NAME], pCuff[80];
                GetPlayerName(playerid, Name, sizeof(Name));
                format(pCuff, sizeof(pCuff), "{FFDC2E}[CUFFED] {FFFFFF}You have been cuffed by %s(%i)", Name, playerid);
                SendClientMessage(targetid, COLOR_WHITE, pCuff);
                GetPlayerName(targetid, Name, sizeof(Name));
                format(pCuff, sizeof(pCuff), "{FFDC2E}[CUFFED] {FFFFFF}You have placed cuffs on %s(%i)", Name, targetid);
                SendClientMessage(playerid, COLOR_WHITE, pCuff);
                SetPlayerSpecialAction(targetid, SPECIAL_ACTION_CUFFED);
                playerData[targetid][uncuffTimer] = SetTimerEx("uncuff", 60000, false, "i", targetid);
                playerData[playerid][recuffTimer] = SetTimerEx("recuff", 5000, false, "i", playerid);
                playerData[playerid][playerCanCuff] = false;
                playerData[targetid][playerIsCuffed] = true;
                if(playerData[targetid][playerIsTied])
                {
                    playerData[targetid][playerIsTied] = false;
                    KillTimer(playerData[targetid][untieTimer]);
                }
            }
            default: SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}This command can only be used by the LEO classes.");
        }
    }
    return 1;
}

GetClosestSuspect(playerid, minimum_wantedlevel)
{
    new Float:dist = 1000.0, targetid = INVALID_PLAYER_ID, Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2, Float:tmpdis;
    GetPlayerPos(playerid, x1, y1, z1);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if(i == playerid) continue;
        if(playerData[i][playerClass] != CLASS_CIVILIAN && playerData[i][playerClass] != CLASS_MEDIC) continue;
        if(playerData[i][playerWantedLevel] < minimum_wantedlevel) 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;
}
Reply
#4

it's wrong,sorry i didn't tell what i need

what i need is
LEO can cuff without submit the id of player
feels like i just cuff with closest player with /cuff
Reply
#5

That's... what... it does...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)