[EJECT PASSANGER ] [+REP]
#1

Hello im wondering is possible to make player eject his players only? I want examples And thanks x)
Reply
#2

Quote:
Originally Posted by SPA
Посмотреть сообщение
Hello im wondering is possible to make player eject his players only? I want examples And thanks x)
Player eject his players ? Can you explain further please..
Reply
#3

Quote:
Originally Posted by SPA
Посмотреть сообщение
Hello im wondering is possible to make player eject his players only? I want examples And thanks x)
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 Код:
if(!(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)) return 1;//stops the cmd if that guy ain't the driver
to the top of your eject command
Reply
#4

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.
Reply
#5

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
Reply
#6

Quote:
Originally Posted by CutX
Посмотреть сообщение
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 Код:
if(!(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)) return 1;//stops the cmd if that guy ain't the driver
to the top of your eject command
I dont think this will eject the passangers
Reply
#7

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.
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.
Reply
#8

Quote:
Originally Posted by SPA
Посмотреть сообщение
I dont think this will eject the passangers
correct, it wasn't meant to be abel to eject a client from a vehicle.

i did say that this is a control structure to check if the client executing
this command is actuallythe driver or not.

this is only the control strudture.
i didn't understand yu correctly at first so i tought that's what you've wanted.

a finished command for something like this would look like
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;
}
but just copy & paste is not good, provide some code next time
Reply
#9

Maybe this ?
pawn Код:
#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;
}
Reply
#10

Quote:
Originally Posted by SPA
Посмотреть сообщение
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.
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.");

    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;
}
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)