/detain command
#1

Hello, I created a /detain command quickly the other day but, it seems to not be working. Here are the required functions.

PHP код:
CMD:detain(playeridparams[])
{
    new 
playerbseatidstring[128];
    if(!
IsPlayerLoggedIn(playerid)) return SendClientMessage(playeridCOLOR_GREY"You need to login first before using any command.");
    if(!
IsACop(playerid) && !IsFBI(playerid) &&!IsSASD(playerid)) return SendClientMessage(playeridCOLOR_GREY"You are not an LSPD Oficer/FBI Agent.");
    if(
sscanf(params"ui"playerbseatid)) return SendClientMessage(playeridCOLOR_WHITE"USAGE: /detain [playerid] [seatid]");
    if(!
IsPlayerLoggedIn(playerb)) return SendClientMessage(playeridCOLOR_GREY"Invalid player id.");
    if(!
IsPlayerNearPlayer(playeridplayerb2)) return SendClientMessage(playeridCOLOR_GREY"You can't detain someone from this disatance.");
    if(!
IsPlayerCuffed(playerb)) return SendClientMessage(playeridCOLOR_GREY"Player is not cuffed.");
    if(
seatid || seatid 3) return SendClientMessage(playeridCOLOR_GREY"You can only detain people in seats 2 and 3.");
    new 
vehicle;
     
vehicle GetPlayerVehicleID(playerid);
    if(
GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
    {
          
PutPlayerInVehicle(playerbLastCar[playerid], seatid);
    }
    else
    {
        
PutPlayerInVehicle(playerbvehicleseatid);
    }
    
format(stringsizeof(string), "* %s grabs %s from their cuffs and throws him inside the LSPD cruiser."RPN(playerid), RPN(playerb));
    
SendNearbyMessage(playerid15stringCOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLE);
    return 
1;

OnPlayerExitVehicle

PHP код:
if(PlayerInfo[playerid][pFac] == && PlayerInfo[playerid][pFac] == && PlayerInfo[playerid][pFac] == 6)
    {
        
LastCar[playerid] = vehicleid;
    }

Reply
#2

What do you mean by doesn't work? Player isn't sent into car?

Your method with LastCar[playerid] isn't too good, it will allow police fractions to throw people into any vehicle. I suggest assigning cop to car on duty start, or something.

Quote:

Hint: new vehicle; vehicle = GetPlayerVehicleID(playerid); is the same as new vehicle = GetPlayerVehicleID(playerid);

Reply
#3

Correct they aren't sent to the vehicle.
Reply
#4

Debug the code mate.

Use print("1");

and 2 and 3 and so on for each section and say which one it stops at.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)