SA-MP Forums Archive
Car Delete - 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)
+--- Thread: Car Delete (/showthread.php?tid=367014)



Car Delete - x96664 - 08.08.2012

Hi, can somebody help me to make a /deletecar command (only for admin) to delete player's car if he is on the driver state and send a reason. If the player is passenger to send a error message to the admin
Код:
[Error:]This player is not in a vehicle or is not a driver!
and also a reason for deleting the vehicle of player. An example for the message for the player:
Код:
Your vehicle has been deleted by admin %s [Reason:%s]



Respuesta: Car Delete - [DOG]irinel1996 - 08.08.2012

I didn't test it, should work:
pawn Код:
COMMAND:deletecar(playerid, params[])
{
    new p, r[128], s[128], name[MAX_PLAYER_NAME];
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"You're not allowed to use this command!");
    if(sscanf(params,"ds[128]",p,r)) return SendClientMessage(playerid,-1,"Usage: /deletecar [Player ID] [Reason]");
    if(!IsPlayerInAnyVehicle(p)) return SendClientMessage(playerid,-1,"That player isn't in any vehicle!");
    DestroyVehicle(GetPlayerVehicleID(p));
    GetPlayerName(playerid,name,MAX_PLAYER_NAME);
    format(s,128,"Your vehicle has been destroyed by admin %s. [Reason: %s]",name,r);
    SendClientMessage(p,-1,s);
    GetPlayerName(p,name,MAX_PLAYER_NAME);
    format(s,128,"You destroyed %s's vehicle. [Reason: %s]",name,r);
    SendClientMessage(p,-1,s);
    return 1;
}
Also I can make a strcmp/strtok version if you need them. :P


Re: Respuesta: Car Delete - x96664 - 08.08.2012

Quote:

Also I can make a strcmp/strtok version if you need them. :P

Please make it and why it is not checking is the player driver or it's not possible?


Respuesta: Car Delete - [DOG]irinel1996 - 08.08.2012

It's possible:
pawn Код:
COMMAND:deletecar(playerid, params[])
{
    new p, r[128], s[128], name[MAX_PLAYER_NAME];
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"You're not allowed to use this command!");
    if(sscanf(params,"ds[128]",p,r)) return SendClientMessage(playerid,-1,"Usage: /deletecar [Player ID] [Reason]");
    if(!IsPlayerInAnyVehicle(p)) return SendClientMessage(playerid,-1,"That player isn't in any vehicle!");
    if(GetPlayerState(p) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid,-1,"That player isn't the driver!");
    DestroyVehicle(GetPlayerVehicleID(p));
    GetPlayerName(playerid,name,MAX_PLAYER_NAME);
    format(s,128,"Your vehicle has been destroyed by admin %s. [Reason: %s]",name,r);
    SendClientMessage(p,-1,s);
    GetPlayerName(p,name,MAX_PLAYER_NAME);
    format(s,128,"You destroyed %s's vehicle. [Reason: %s]",name,r);
    SendClientMessage(p,-1,s);
    return 1;
}
Also, what do you use? strtok and strcmp?
Best regards!