Goto Command.
#5

You have to check a empty seat before to place the player on it. So.. use it:

Код HTML:
CMD:goto(playerid, params[])
{
	if(playerVariables[playerid][pAdminLevel] >= 1)
	{
	    new userID;
	    new vehicleid = GetPlayerVehicleID(userID);
		if(sscanf(params, "u", userID)) {
		 return SendClientMessage(playerid, COLOR_GREY, SYNTAX_MESSAGE"/goto [playerid]");
		}
		else {
		    if(!IsPlayerConnected(userID)) return SendClientMessage(playerid, COLOR_GREY, "The specified player ID is either not connected or has not authenticated.");
		    new messageString[64];
		    new Float: fPos[3];
		    GetPlayerPos(userID, fPos[0], fPos[1], fPos[2]);
		    if(IsPlayerInAnyVehicle(userID) && GetPlayerState(userID) == PLAYER_STATE_DRIVER)
		    {
				LinkVehicleToInterior(GetPlayerVehicleID(playerid), GetPlayerInterior(userID));
				SetVehicleVirtualWorld(GetPlayerVehicleID(playerid), GetPlayerVirtualWorld(userID));
		 		PutPlayerInVehicle(playerid, vehicleid, 1);
		 		SetPlayerPos(playerid, fPos[0]+2, fPos[1], fPos[2]);
		    }
		    else if(IsPlayerInAnyVehicle(userID) && getEmptySeat(GetPlayerVehicleID(userID))>-1){
				PutPlayerInVehicle(playerid, GetPlayerVehicleID(userID), getEmptySeat(GetPlayerVehicleID(userID)));
				}
			else
			{
			    SetPlayerPos(playerid, fPos[0]+2, fPos[1], fPos[2]);
			    SetVehiclePos(GetPlayerVehicleID(playerid), fPos[0], fPos[1]+2, fPos[2]);
			}
   			SetPlayerInterior(playerid, GetPlayerInterior(userID));
			SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(userID));
   			GetPlayerName(userID, szPlayerName, MAX_PLAYER_NAME);
			format(messageString, sizeof(messageString), "You have teleported to %s.", szPlayerName);
			SendClientMessage(playerid, COLOR_WHITE, messageString);
			IsOnDM[playerid] = IsOnDM[userID];
			InBizz[playerid] = InBizz[userID];
			InHouse[playerid] = InHouse[userID];
			InHQ[playerid] = InHQ[userID];
		}
	}
	return 1;
}
Add:

Код HTML:
stock getEmptySeat(vehicleid) {
	new i, free;
	for(i=0; i<GetMaxSeats(vehicleid); i++){
		free = i;
		foreach(Player, x) {
			if(GetPlayerVehicleID(x) == vehicleid && GetPlayerVehicleSeat(x) == i) free = -1;
		}
		if(free!=-1) return i;
	}
	return -1;
}
stock GetMaxSeats(vehicleid){
    return MaxSeats[(GetVehicleModel(vehicleid) - 400)];
}

stock checkVehicleSeat(vehicleid, seatid) {
	foreach(Player, x) {
	    if(GetPlayerVehicleID(x) == vehicleid && GetPlayerVehicleSeat(x) == seatid) return 1;
	}
	return 0;
}

new MaxSeats[212] = {
4,2,2,2,4,4,1,2,2,4,2,2,2,4,2,2,4,2,4,2,4,4,2,2,2,1,4,4,4,2,1,9,1,2,2,1,2,9,4,2,
4,1,2,2,2,4,1,2,1,6,1,2,1,1,1,2,2,2,4,4,2,2,2,2,2,2,4,4,2,2,4,2,1,1,2,2,1,2,2,4,
2,1,4,3,1,1,1,4,2,2,4,2,4,1,2,2,2,4,4,2,2,2,2,2,2,2,2,4,2,1,1,2,1,1,2,2,4,2,2,1,
1,2,2,2,2,2,2,2,2,4,1,1,1,2,2,2,2,0,0,1,4,2,2,2,2,2,4,4,2,2,4,4,2,1,2,2,2,2,2,2,
4,4,2,2,1,2,4,4,1,0,0,1,1,2,1,2,2,2,2,4,4,2,4,1,1,4,2,2,2,2,6,1,2,2,2,1,4,4,4,2,
2,2,2,2,4,2,1,1,1,4,1,1
};
Reply


Messages In This Thread
Goto Command. - by Digii - 16.05.2016, 11:17
Re: Goto Command. - by F1N4L - 16.05.2016, 11:20
Re: Goto Command. - by Digii - 16.05.2016, 11:25
Re: Goto Command. - by F1N4L - 16.05.2016, 11:28
Re: Goto Command. - by Nin9r - 16.05.2016, 11:54
Re: Goto Command. - by Amunra - 16.05.2016, 11:59
Re: Goto Command. - by Sew_Sumi - 16.05.2016, 12:33
Re: Goto Command. - by Nin9r - 16.05.2016, 13:01
Re: Goto Command. - by Digii - 16.05.2016, 13:31
Re: Goto Command. - by Sew_Sumi - 16.05.2016, 13:49

Forum Jump:


Users browsing this thread: 2 Guest(s)