08.04.2014, 11:38
Hello im wondering is possible to make player eject his players only? I want examples And thanks x)
Hello im wondering is possible to make player eject his players only? I want examples And thanks x)
|
if(!(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)) return 1;//stops the cmd if that guy ain't the driver
CMD:eject(playerid, params[])
{
if(!GetPlayerState(playerid) == PLAYER_STATE_DRIVER) return SendClientMessage(playerid, -1, "You aren't the driver of a vehicle.");
new giveplayerid;
if (sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, -1, "USAGE: /eject [playerid]");
if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, -1, "Invalid Player ID/Name Specified.");
new vehicleid = GetPlayerVehicleID(playerid));
new vehicleid2 = GetPlayerVehicleID(giveplayerid));
if(vehicleid != vehicleid2) return SendClientMessage(playerid, -1, "They aren't in your vehicle.");
new string[128];
format(string, sizeof(string), "You have been ejected by Driver %s.", GetName(playerid));
SendClientMessage(giveplayerid, -1, string);
format(string, sizeof(string), "You have ejected passenger %s.", GetName(giveplayerid));
SendClientMessage(playerid, -1, string);
return 1;
}
pawn Код:
|
if(!GetPlayerState(playerid) == PLAYER_STATE_DRIVER) return SendClientMessage(playerid, -1, "You aren't the driver of a vehicle.");
if(!(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)) return SendClientMessage(playerid, -1, "You aren't the driver of a vehicle.");
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, -1, "You aren't the driver of a vehicle.");
Originally Posted by http://forum.sa-mp.com/announcement.php?f=12
Do Not Post Untested Code - If you are replying to a problem and you haven't confirmed that your code will work, you are likely to make the problem worse, not better.
|
okey, you you want an eject command which only works when you are the driver of the vehicle?
so that the player who's driving can eject other players and noone else can correct? if that's what you want, add pawn Код:
|
pawn Код:
|
YCMD:eject(playerid, params[], help)
{
if(help) SendClientMessage(playerid, gray, "/eject is used to eject a player from a vehicle");
new id;
if(sscanf(params,"d",id)) return SendClientMessage(playerid,red,"USAGE: /eject [Player-ID]");
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,red,"You have to be the driver of a vehicle");
if(id == playerid) return SendClientMessage(playerid,red,"You can't eject yourself...");
if(GetPlayerVehicleID(playerid) != GetPlayerVehicleID(id)) return SendClientMessage(playerid,red,"That player ain't here...");
if(!(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)) return SendClientMessage(playerid,red,"You're not the driver of this vehicle.");
RemovePlayerFromVehicle(id);
GameTextForPlayer(id,"you got ~r~ejected!",3000,3);
SendClientMessage(playerid,-1,"you've just ejected that player.");
return 1;
}
#include <a_samp>
#include <zcmd>
#include <sscanf>
CMD:eject(playerid,params[])
{
new id,Float:x, Float:y, Float:z, string[500];
if(sscanf(params, "u", id)) return SendClientMessage(playerid, -1, "[USAGE]: /eject [playerid]!");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "[ERROR]: Player is not connected/wrong ID!");
if(!IsPlayerInAnyVehicle(id)) return SendClientMessage(playerid, -1, "[ERROR]: Player is not on a vehicle!");
GetPlayerPos(id,x,y,z);
format(string,sizeof(string),"You ejected '%s' from vehicle",name(id));
SendClientMessage(playerid,-1,string);
SetPlayerPos(id,x,y,z+3);
return 1;
}
stock name(playerid)
{
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid,Name,MAX_PLAYER_NAME);
return Name;
}
C:\Users\MaHdy\Desktop\SPA Orginal Build 2\pawno\include\sscanf.inc(1) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\MaHdy\Desktop\SPA Orginal Build 2\gamemodes\SPA.pwn(5896) : warning 213: tag mismatch C:\Users\MaHdy\Desktop\SPA Orginal Build 2\gamemodes\SPA.pwn(5900) : error 001: expected token: ";", but found ")" C:\Users\MaHdy\Desktop\SPA Orginal Build 2\gamemodes\SPA.pwn(5900) : error 029: invalid expression, assumed zero C:\Users\MaHdy\Desktop\SPA Orginal Build 2\gamemodes\SPA.pwn(5900) : warning 215: expression has no effect C:\Users\MaHdy\Desktop\SPA Orginal Build 2\gamemodes\SPA.pwn(5901) : error 001: expected token: ";", but found ")" C:\Users\MaHdy\Desktop\SPA Orginal Build 2\gamemodes\SPA.pwn(5901) : error 029: invalid expression, assumed zero C:\Users\MaHdy\Desktop\SPA Orginal Build 2\gamemodes\SPA.pwn(5901) : warning 215: expression has no effect C:\Users\MaHdy\Desktop\SPA Orginal Build 2\gamemodes\SPA.pwn(5903) : error 017: undefined symbol "GetName" C:\Users\MaHdy\Desktop\SPA Orginal Build 2\gamemodes\SPA.pwn(5905) : error 017: undefined symbol "GetName" Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 6 Errors. |
CMD:eject(playerid, params[])
{
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, -1, "You aren't the driver of a vehicle.");
new giveplayerid;
if (sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, -1, "USAGE: /eject [playerid]");
if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, -1, "Invalid Player ID/Name Specified.");
new vehicleid = GetPlayerVehicleID(playerid);
new vehicleid2 = GetPlayerVehicleID(giveplayerid);
if(vehicleid != vehicleid2) return SendClientMessage(playerid, -1, "They aren't in your vehicle.");
format(string, sizeof(string), "You have been ejected by Driver %s.", GetName(playerid));
SendClientMessage(giveplayerid, -1, string);
format(string, sizeof(string), "You have ejected passenger %s.", GetName(giveplayerid));
SendClientMessage(playerid, -1, string);
RemovePlayerFromVehicle(giveplayerid);
return 1;
}
stock GetName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof name);
return name;
}