get in player vehicle
#1

i try to create a cmd for admins to get in player's vehicle while they are on foot but i keep failing.
anyone please help?
Код:
CMD:gv(playerid, params[])
{
	new id;
    if(PlayerAcc[playerid][Log] == 0) return SendClientMessage(playerid, COLOR_RED, "Error: You are not logged in!");
	if(PlayerAcc[playerid][Admin] >= 3)
	{
		if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_RED, "Gv: /gv (id)");
		if(id == INVALID_PLAYER_ID) return ErrorMessages(playerid, 2);
	    if(id == playerid) return ErrorMessages(playerid, 4);
        if(IsPlayerInVehicle(id))
		if(GetPlayerState(playerid) == 2)
		{
		PutPlayerInVehicle(playerid, CarId[id], 1);
		}
	}
	return 1;
}
please help me
Reply
#2

You want them only to TP if they are inside a vehicle already?
Reply
#3

yes. only for admins who are standing on foots to tele themself into a player's vehicle
Reply
#4

pawn Код:
CMD:gv(playerid, params[])
{
    new id;
    if(PlayerAcc[playerid][Log] == 0) return SendClientMessage(playerid, COLOR_RED, "Error: You are not logged in!");
    if(PlayerAcc[playerid][Admin] >= 3)
    {
        if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_RED, "Gv: /gv (id)");
        if(id == INVALID_PLAYER_ID) return ErrorMessages(playerid, 2);
        if(id == playerid) return ErrorMessages(playerid, 4);
        if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
        {
            if(id == INVALID_VEHICLE_ID) return SendClientMessage(playerid, COLOR_RED, "Gv: That vehicle doesn't exist");
            PutPlayerInVehicle(playerid, id, 0);
        }
        else return SendClientMessage(playerid, COLOR_GREY, "Gv: You must be on foot");
    }
    return 1;
}
Reply
#5

Quote:

error 017: undefined symbol "IsValidVehicle"

the line
Quote:

if(!IsValidVehicle(id)) return SendClientMessage(playerid, COLOR_RED, "Gipv: That vehicle doesn't exist");

Reply
#6

Put this near the top of your gm:
pawn Код:
native IsValidVehicle(vehicleid);
Reply
#7

it work but it put me other vehicle that where not spawned by player and when i spawn a car and he use that command to get in my car it say "That vehicle doesn't exist"
Reply
#8

try
pawn Код:
CMD:gv(playerid, params[])
{
    new id;
    if(PlayerAcc[playerid][Log] == 0) return SendClientMessage(playerid, COLOR_RED, "Error: You are not logged in!");
    if(PlayerAcc[playerid][Admin] >= 3)
    {
        if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_RED, "Gv: /gv (id)");
        if(id == INVALID_PLAYER_ID) return ErrorMessages(playerid, 2);
        if(id == playerid) return ErrorMessages(playerid, 4);
        if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
        {
            if(id == INVALID_VEHICLE_ID) return SendClientMessage(playerid, COLOR_RED, "Gv: That vehicle doesn't exist");
            PutPlayerInVehicle(playerid, id, 0);
        }
        else return SendClientMessage(playerid, COLOR_GREY, "Gv: You must be on foot");
    }
    return 1;
}
Reply
#9

still giving me problems but i will find a way to fix it thanks for helping me +rep
Reply
#10

"id" is the player ID and not the vehicle ID.
The "seatid" shouldn't be 0 but the first passenger (1).

PHP код:
CMD:gv(playeridparams[])
{
    if(!
PlayerAcc[playerid][Log]) return SendClientMessage(playeridCOLOR_RED"Error: You are not logged in!");
    if(
PlayerAcc[playerid][Admin] >= 3)
    {
        new 
id;
        if(
sscanf(params"u"id)) return SendClientMessage(playeridCOLOR_RED"Gv: /gv (id)");
        if(
id == INVALID_PLAYER_ID) return ErrorMessages(playerid2);
        if(
id == playerid) return ErrorMessages(playerid4);
        if(
GetPlayerState(id) != PLAYER_STATE_DRIVER) return SendClientMessage(playeridCOLOR_GREY"The player is not a driver");
        if(
GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return SendClientMessage(playeridCOLOR_GREY"You must be on foot");
        
PutPlayerInVehicle(playeridGetPlayerVehicleID(id), 1);
    }
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)