Team car's. Rep +
#1

Hello guys, I'm working on my drifting/RP server and now it's time to make team's.
I have created police, drifter and mafia and they work fine. But now I want them to have cars.
This is what I have:
pawn Код:
new Cars[TeamCars];

enum TeamCars
{
Drifter,
Cops
}

public OnGameModeInit()
{
    AddPlayerClass(105,-183.5194,1090.8673,19.7422,52.6484,0,0,0,0,0,0); // 0
    AddPlayerClass(282,1607.0870,1815.6981,10.8203,193.8336,0,0,0,0,0,0);
    AddPlayerClass(29,1124.0724,-2037.0490,69.8852,270.1483,0,0,0,0,0,0);
    Cars[Drifter] = AddStaticVehicle(562,1244.0070,-2042.9696,59.5858,1.3234,17,1); // bil
      Cars[Cops] = AddStaticVehicle(596,1244.1085,-2063.5588,59.7767,287.2261,0,0);

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate && 2)
    {
        new CarCheck = GetPlayerVehicleID(playerid);
        if(CarCheck == Cars[Cops] )
        {
            if(gTeam[playerid] != 1)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_RED, "You cant' drive this car!");
                return 1;
            }
        }
        if(CarCheck == Cars[Drifter] )
        {
            if(gTeam[playerid] != 2)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_RED, "You can't drive this car!");
                return 1;
            }
        }
        return 1;
    }
    return 1;
}
And it seems to work but when im a drifter and enter a elegy I get kicked out and when I enter a police car I don't get kicked out. Please help!
Reply
#2

something like this i think you will figure it out.
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
new classid;
    if(vehicleid == CarsDrifter)
    {
        if(classid == ClassDrift)
        {
        }
        else
        {
            GetPlayerPos(playerid,x,y,z);
            SetPlayerPos(playerid,x,y,z);
        }
    }
    else if(vehicleid == CarsCops)
    {
        if(classid == ClassCops)
        {
        }
        else
        {
            GetPlayerPos(playerid,x,y,z);
            SetPlayerPos(playerid,x,y,z);
        }
    }
    return 1;
}
public OnGameModeInit()
{
    ClassDrift = AddPlayerClass(282,1607.0870,1815.6981,10.8203,193.8336,0,0,0,0,0,0);
    ClassCops = AddPlayerClass(29,1124.0724,-2037.0490,69.8852,270.1483,0,0,0,0,0,0);
    CarsDrifter = AddStaticVehicle(562,1244.0070,-2042.9696,59.5858,1.3234,17,1); // bil
    CarsCops = AddStaticVehicle(596,1244.1085,-2063.5588,59.7767,287.2261,0,0);
    return 1;
}
Reply
#3

Isn't easier to use OnPlayerStateChange?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)