/eject
#1

Код:
CMD:eject(playerid, params[])
{
	if(GetPlayerVehicleID(playerid))
	if(IsPlayerAdmin(playerid))
	{
		RemovePlayerFromVehicle(playerid);
		SendClientMessage(playerid, -1, "Player got Ejected!");
	}
	else SendClientMessage(playerid,RED,"[AG] You do not have enough Admin Permissions to execute this Command!");
	return 1;
}
How to make this command to a specifc player? By ID.
Reply
#2

makng a variable target to work on target. The code below is an example on how to make a command effect on a player.

pawn Код:
CMD:eject(playerid, params[])
{
    new target
    if(sscanf(params, "ui", target, level)) return SendClientMessage(playerid, COLOR_ORANGE, "[*] Usage: /makeadmin [playerid/name] [level]");
    else if(target == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_ORANGE, "[*] Enter a valid player ID/name!");
    if(GetPlayerVehicleID(playerid))
    if(IsPlayerAdmin(playerid))
    {
    new string[128], pName[MAX_PLAYER_NAME];
    GetPlayerName(target, pName, MAX_PLAYER_NAME);
    RemovePlayerFromVehicle(playerid);
    format(string, sizeof string, "%s has been ejected", pName);
    SendClientMessage(playerid,string);
    }
    else SendClientMessage(playerid,RED,"[AG] You do not have enough Admin Permissions to execute this Command!");
    return 1;
}
but it requires sscanf.
Reply
#3

That didnt work. Is it for a admin system or rcon admin? As Iam using rcon.
I got sscanf2
Reply
#4

Change
pawn Код:
RemovePlayerFromVehicle(playerid);
To
pawn Код:
RemovePlayerFromVehicle(target);
Reply
#5

pawn Код:
CMD:eject(playerid, params[])
{
    new ID;
    if(!IsPlayerAdmin(playerid)) SendClientMessage(playerid,RED,"[AG] You do not have enough Admin Permissions to execute this Command!");
    else if(isnull(params)) SendClientMessage(playerid,-1,"Usage: /eject [playerid]");
    else if(!IsPlayerConnected((ID = strval(params)))) SendClientMessage(playerid,RED,"Player is not online");
    else{
        new veh = GetPlayerVehicleID(ID);
        if(veh == 0 || veh == INVALID_VEHICLE_ID) SendClientMessage(playerid,RED,"Player is not in vehicle");
        else{
            RemovePlayerFromVehicle(ID);
            SendClientMessage(playerid, -1, "Player got Ejected!");
        }
    }
    return 1;
}
Reply
#6

You need sscanf2 include/plugin and zcmd include.

Code:
PHP код:
CMD:eject(playeridparams[])
{
    new 
targetidstring[128], N[MAX_PLAYER_NAME];
    new 
name GetPlayerName(targetidNsizeof(N));
    if(
sscanf(params"u"targetid)) return SendClientMessage(playerid, -1"USAGE: /eject [playerid]");
    if(!
IsPlayerInAnyVehicle(targetid)) return SendClientMessage(playerid, -1"ERROR: Player is not in a vehicle");
    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1"ERROR: You must be an Administrator to use this command");
    
RemovePlayerFromVehicle(targetid);
    
format(stringsizeof(string), "Player %s has been ejected of his vehicle"name);
    
SendClientMessageToAll(-1string);
    return 
1;

Reply
#7

THank you!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)