Quote:
Originally Posted by Abagail
pawn Код:
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; }
Untested.
|
dude ^^
this code will fail hard, it'll be as if that if(!GetPlayerState...... line never existed :P
cuz of this line
Код:
if(!GetPlayerState(playerid) == PLAYER_STATE_DRIVER) return SendClientMessage(playerid, -1, "You aren't the driver of a vehicle.");
you can't just use the negation operator like this.
you have to use braces
Код:
if(!(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)) return SendClientMessage(playerid, -1, "You aren't the driver of a vehicle.");
or do it like this
Код:
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, -1, "You aren't the driver of a vehicle.");
"untested" ?
quoting the rules:
Quote:
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.
|
- no offense