San Fierro Trolley car
#7

Quote:
Originally Posted by Tellken
Посмотреть сообщение
Serнa algo como esto

El valor de TRAMID es el id del coche en tu server, el que te de el /dl.

El cуdigo es tan sencillo gracias a la funciуn IsVehicleSeatOccupied, que no es nativa del samp:

pawn Код:
#define TRAMID    VALOR

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/tranvia", true) == 0)
    {
        new Float:x, Float:y, Float:z;
        GetVehiclePos(TRAMID, x, y, z);
        if(IsPlayerInRangeOfPoint(playerid, 10.0, x, y, z))
        {
            if(!IsVehicleSeatOccupied(TRAMID, 1)) PutPlayerInVehicle(playerid, TRAMID, 1);
            if(!IsVehicleSeatOccupied(TRAMID, 2)) PutPlayerInVehicle(playerid, TRAMID, 2);
            if(!IsVehicleSeatOccupied(TRAMID, 3)) PutPlayerInVehicle(playerid, TRAMID, 3);
            if(!IsVehicleSeatOccupied(TRAMID, 4)) PutPlayerInVehicle(playerid, TRAMID, 4);
            if(!IsVehicleSeatOccupied(TRAMID, 5)) PutPlayerInVehicle(playerid, TRAMID, 5);
            SendClientMessage(playerid, 0x02b1afFF, "* Has subido al tranvнa. Para salir usa /salirtranvia.");
        }
        else return SendClientMessage(playerid, 0xFF6347FF, "* Demasiado lejos.");
        return 1;
    }
    if(strcmp(cmdtext, "/salirtranvia", true) == 0)
    {
        RemovePlayerFromVehicle(playerid);
        SetCameraBehindPlayer(playerid);
        return 1;
    }
    return 0;
}

stock IsVehicleSeatOccupied(vehicleid,seatid)
{
    if(!GetVehicleModel(vehicleid)) return 0;
    foreach(new i: Player)
    {
        if(IsPlayerInVehicle(i,vehicleid) && GetPlayerVehicleSeat(i) == seatid)
        {
            return 1;
        }
    }
    return 0;
}
Here is code for Trolley car San Fierro.

Код:
#define TRAMID 2

AddStaticVehicleEx(449,-2006.9436, 211.0592, 27.5391, 0.0, 0, 1, 1);

CMD:tranvia(playerid, params[])
{
new Float:x, Float:y, Float:z;
GetVehiclePos(TRAMID, x, y, z);
if(IsPlayerInRangeOfPoint(playerid, 10.0, x, y, z))
{
PutPlayerInVehicle(playerid, TRAMID, 0);
}
else return SendClientMessage(playerid, 0xFF6347FF, "* Demasiado lejos.");
return 1;
}
CMD:subirtranvia(playerid, params[])
{
	new Float:x, Float:y, Float:z;
	GetVehiclePos(TRAMID, x, y, z);
	if(IsPlayerInRangeOfPoint(playerid, 10.0, x, y, z))
	{
		if(!IsVehicleSeatOccupied(TRAMID, 1)) PutPlayerInVehicle(playerid, TRAMID, 1);
		if(!IsVehicleSeatOccupied(TRAMID, 2)) PutPlayerInVehicle(playerid, TRAMID, 2);
		if(!IsVehicleSeatOccupied(TRAMID, 3)) PutPlayerInVehicle(playerid, TRAMID, 3);
		if(!IsVehicleSeatOccupied(TRAMID, 4)) PutPlayerInVehicle(playerid, TRAMID, 4);
		if(!IsVehicleSeatOccupied(TRAMID, 5)) PutPlayerInVehicle(playerid, TRAMID, 5);
		SendClientMessage(playerid, 0x02b1afFF, "* Has subido al tranvнa. Para salir usa /salirtranvia.");
	}
	else return SendClientMessage(playerid, 0xFF6347FF, "* Demasiado lejos.");
	return 1;
}
CMD:salirtranvia(playerid, params[])
{
	RemovePlayerFromVehicle(playerid);
	SetCameraBehindPlayer(playerid);
	return 1;
}

stock IsVehicleSeatOccupied(vehicleid,seatid)
{
	if(!GetVehicleModel(vehicleid)) return 0;
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerInVehicle(i,vehicleid) && GetPlayerVehicleSeat(i) == seatid)
		{
			return 1;
		}
	}
	return 0;
}
Reply


Messages In This Thread
San Fierro Trolley car - by bookknp - 31.03.2018, 01:37
Re: San Fierro Trolley car - by Abagail - 31.03.2018, 01:49
Re: San Fierro Trolley car - by bookknp - 31.03.2018, 02:03
Re: San Fierro Trolley car - by Abagail - 31.03.2018, 06:25
Re: San Fierro Trolley car - by MadeMan - 31.03.2018, 09:39
Re: San Fierro Trolley car - by Tellken - 01.04.2018, 02:00
Re: San Fierro Trolley car - by bookknp - 05.04.2018, 16:48

Forum Jump:


Users browsing this thread: 1 Guest(s)