PDA

View Full Version : /eject works only with id 0


Face9000
01/06/2012, 12:11 PM
Ok so,i coded this little /eject command,but it works only if i want eject id 0.

CMD:ej(playerid,params[])
{
if(!strlen(params)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /ej [Player/ID]");
new string[128];
new string2[128];
new DestName[24];
new Destinationid;
new name[24];
GetPlayerName(playerid, name, 24);
GetPlayerName(Destinationid, DestName, 24);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER && IsPlayerInVehicle(Destinationid, GetPlayerVehicleID(playerid)))
{
if(IsPlayerConnected(Destinationid) && playerid != Destinationid)
{
format(string2, 128, "You have ejected %s (%i) from your vehicle.", DestName, Destinationid);
SendClientMessage(playerid, orange, string2);
GameTextForPlayer(playerid,"~r~Player ejected from vehicle!",3000,5);

format(string, 128, "You got ejected from %s's (%d) vehicle.", name, playerid);
SendClientMessage(playerid, orange, string);
RemovePlayerFromVehicle(Destinationid);
GameTextForPlayer(Destinationid,"~r~You have been ejected!",3000,5);
}
}
return true;
}

What's wrong?

ReneG
01/06/2012, 12:27 PM
Hahahahah I ******d "sscanf 0 ID bug"

http://forum.sa-mp.com/showthread.php?t=339361

Face9000
01/06/2012, 12:29 PM
Hahahahah I ******d "sscanf 0 ID bug"

http://forum.sa-mp.com/showthread.php?t=339361

Lol my sscanf is updated,all other commands works good.

MadeMan
01/06/2012, 12:31 PM
You should use sscanf in this command.

Face9000
01/06/2012, 12:32 PM
Fixed,thanks.

JaKe Elite
01/06/2012, 12:47 PM
Hahahahah I ******d "sscanf 0 ID bug"

http://forum.sa-mp.com/showthread.php?t=339361

lol?

Sandiel
01/06/2012, 01:27 PM
Try this, you'll need ZCMD, and sscanf
COMMAND:eject(playerid, params[])
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER))
{
new targetid;
if(!sscanf(params, "u", targetid))
{
if(GetPlayerState(targetid) == PLAYER_STATE_PASSENGER))
{
new vehID;
vehID = GetPlayerVehicleID(playerid);
new Float:vehX, Float:vehY, Float:vehZ;
GetVehiclePos(vehID, vehX, vehY, vehZ);
SetPlayerPos(targetid, vehX, vehY+2, vehZ);
SendClientMessage(targetid, COLOR_WHITE, "You have been ejected from the vehicle!");
}
}
}
return 1;
}

Adrian9696
01/06/2012, 01:43 PM
Place this command to public OnPlayerCommandText in your game mode
if(strcmp(cmd, "/eject", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new State;
if(IsPlayerInAnyVehicle(playerid))
{
State=GetPlayerState(playerid);
if(State!=PLAYER_STATE_DRIVER)
{
SendClientMessage(playerid,COLOR_GREY," You can only eject people as the driver !");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /eject [playerid/PartOfName]");
return 1;
}
new playa;
playa = ReturnUser(tmp);
new test;
test = GetPlayerVehicleID(playerid);
if(IsPlayerConnected(playa))
{
if(playa != INVALID_PLAYER_ID)
{
if(playa == playerid) { SendClientMessage(playerid, COLOR_GREY, "You cannot Eject yourself!"); return 1; }
if(IsPlayerInVehicle(playa,test))
{
new PName[MAX_PLAYER_NAME];
GetPlayerName(playerid,PName,sizeof(PName));
GetPlayerName(playa, giveplayer, sizeof(giveplayer));
format(string, sizeof(string), "* You have thrown %s out of the car!", giveplayer);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), "* You have been thrown out the car by %s !", PName);
SendClientMessage(playa, COLOR_WHITE, string);
RemovePlayerFromVehicle(playa);
}
else
{
SendClientMessage(playerid, COLOR_GREY, " That player is not in your Car !");
return 1;
}
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " Invalid ID/Name!");
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You need to be in a Vehicle to use this !");
}
}
return 1;
}

JaKe Elite
01/06/2012, 01:54 PM
Its fixed. No need helping.

Need quote? here you go

Fixed,thanks.