Put Player in vehicle command
#1

I wanna make command to put player in my vehicle, but i don't know how to check if the seat is empty.

I have this code:
Code:
stock IsSeatTaken(vehicleid, seatid)
{
    foreach(Player, i)
    {
        if(GetPlayerVehicleID(i) == vehicleid && GetPlayerVehicleSeat(i) == seatid) return 1;
    }
    return 0;
}
AND i have this command:
Code:
CMD:pinc(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] >= 1)
	{
		new id, seatid, AdminName[MAX_PLAYER_NAME], string[128], tt[MAX_PLAYER_NAME], strr[128];
		GetPlayerName(playerid, AdminName, sizeof(AdminName));
		if(sscanf(params, "ud", id, seatid)) return SendClientMessage(playerid, WHITE, "USAGE:/pinc [partofname/playerid] [seatID]");
		if(id == INVALID_PLAYER_ID) SendClientMessage(playerid, RED, "Player not found!");
		if(!IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER) return SendClientMessage(playerid, RED, "You have to be in a car to use this command!");
		if(seatid >= 4 || seatid < 1) return SendClientMessage(playerid, RED, "Invalid SeatID!");
		new Float:pincX, Float:pincY, Float:pincZ, curtveh, vehseat;
		curtveh = GetPlayerVehicleID(playerid);
		vehseat = GetPlayerVehicleSeat(id);
		foreach(Player, p)
		{
			if(IsSeatTaken)
			{
                        }
                }
		GetVehiclePos(curtveh, pincX, pincY, pincZ);
		PutPlayerInVehicle(id,curtveh,seatid);
        }
	else SendClientMessage(playerid, RED, "You are not a admin!");
	return 1;
}
Reply
#2

PHP Code:
CMD:pinc(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] >= 1)
    {
        new 
idseatidAdminName[MAX_PLAYER_NAME], string[128], tt[MAX_PLAYER_NAME], strr[128];
        
GetPlayerName(playeridAdminNamesizeof(AdminName));
        if(
sscanf(params"ud"idseatid)) return SendClientMessage(playeridWHITE"USAGE:/pinc [partofname/playerid] [seatID]");
        if(
id == INVALID_PLAYER_IDSendClientMessage(playeridRED"Player not found!");
        if(!
IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playeridRED"You have to be in a car to use this command!");
        if(
seatid >= || seatid 1) return SendClientMessage(playeridRED"Invalid SeatID!");
        new 
Float:pincXFloat:pincYFloat:pincZcurtvehvehseat;
        
curtveh GetPlayerVehicleID(playerid);
        
vehseat GetPlayerVehicleSeat(id);
        if(
IsSeatTaken(curtvehseatid)==1reutn SendClientMessage(playeridRED"This seat is already taken.");
        
GetVehiclePos(curtvehpincXpincYpincZ);
        
PutPlayerInVehicle(id,curtveh,seatid);
        }
    else 
SendClientMessage(playeridRED"You are not a admin!");
    return 
1;

Reply
#3

PHP Code:
It Get me some errors in JaKadmin3 
Reply
#4

Code:
stock IsVehicleSeatUsed(vehicleid, seat)
{
	foreach (new i : Player) if (IsPlayerInVehicle(i, vehicleid) && GetPlayerVehicleSeat(i) == seat) {
	    return 1;
	}
	return 0;
}
Reply
#5

Quote:
Originally Posted by NourNN
View Post
PHP Code:
It Get me some errors in JaKadmin3 
Are you trying to code this command out of JakAdmin3? Let me code one for you. I will edit this post in a minute after i have coded it.

Edit:

Here it is, Codes are copy/pasted from ATGOggy but i have removed some unused strings on it / I have also used a code that suits the JakAdmin3 script.

Code:
CMD:pinc(playerid, params[])
{
    LoginCheck(playerid);
    LevelCheck(playerid, 1);
    
    new id, seatid;
    if(sscanf(params, "ud", id, seatid)) return SendClientMessage(playerid, WHITE, "USAGE: /pinc [partofname/playerid] [seatID]");
    if(id == INVALID_PLAYER_ID) SendClientMessage(playerid, RED, "Player not found!");
    if(!IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, RED, "You have to be in a car to use this command!");
    if(seatid >= 4 || seatid < 1) return SendClientMessage(playerid, RED, "Invalid SeatID!");
    new Float:pincX, Float:pincY, Float:pincZ, curtveh, vehseat;
    curtveh = GetPlayerVehicleID(playerid);
    vehseat = GetPlayerVehicleSeat(id);
    if(IsSeatTaken(curtveh, seatid)==1) reutn SendClientMessage(playerid, RED, "This seat is already taken.");
    GetVehiclePos(curtveh, pincX, pincY, pincZ);
    PutPlayerInVehicle(id,curtveh,seatid);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)