/eject works only with id 0
#1

Ok so,i coded this little /eject command,but it works only if i want eject id 0.

pawn Код:
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?
Reply
#2

Hahahahah I ******d "sscanf 0 ID bug"

https://sampforum.blast.hk/showthread.php?tid=339361
Reply
#3

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
Hahahahah I ******d "sscanf 0 ID bug"

https://sampforum.blast.hk/showthread.php?tid=339361
Lol my sscanf is updated,all other commands works good.
Reply
#4

You should use sscanf in this command.
Reply
#5

Fixed,thanks.
Reply
#6

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
Hahahahah I ******d "sscanf 0 ID bug"

https://sampforum.blast.hk/showthread.php?tid=339361
lol?
Reply
#7

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

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

Its fixed. No need helping.

Need quote? here you go

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
Fixed,thanks.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)