SA-MP Forums Archive
get in player vehicle - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: get in player vehicle (/showthread.php?tid=573841)



get in player vehicle - suni - 10.05.2015

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


Re: get in player vehicle - Abagail - 10.05.2015

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


Re: get in player vehicle - suni - 11.05.2015

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


Re: get in player vehicle - Abagail - 11.05.2015

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



Re: get in player vehicle - suni - 11.05.2015

Quote:

error 017: undefined symbol "IsValidVehicle"

the line
Quote:

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




Re: get in player vehicle - Abagail - 11.05.2015

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



Re: get in player vehicle - suni - 11.05.2015

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"


Re: get in player vehicle - Abagail - 11.05.2015

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



Re: get in player vehicle - suni - 11.05.2015

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


Re: get in player vehicle - Konstantinos - 11.05.2015

"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;