[HELP]CAR MISSION
#1

Hello . I have a carmission script that randomly spawns a car and if you take and deliver it you recieve an ammount of money and +1 exp. The problem is that you become wanted player. I want to add if a player is TEAM_COP to do not be able to get in that car, I mean if he gets in it to be ejected from it and to say that : You are a cop you must defend it from stealers. Help me please because idk how to add it. If you need something else or didn't understand feel free to ask me. Here is the code :

pawn Код:
if(MissionActive == 2)
       {
        if(PlayerIsDoingMission == INVALID_PLAYER_ID)
        {
            ResetMissions();
            if(city == 1){SearchedVehicle = MAX_HOUSES+random(sizeof(RandomVehicles_LS)-MAX_HOUSES);} // Avoid housecars and planes can be 'searched'
            RandomCarMissionMoney = MinCarMissionMoney+random(MaxCarMissionMoney-MinCarMissionMoney);
            format(string, sizeof(string), "Mission: Car Export! Find the %s at the red marker, Worth: %d$", VehicleName[GetVehicleModel(SearchedVehicle)-400], RandomCarMissionMoney);
            SendClientMessageToAll(COLOR_YELLOW, string);
            new Float:vehx, Float:vehy, Float:vehz;
            new Float:ratio = 4.0;
            GetVehiclePos(SearchedVehicle, vehx, vehy, vehz);
            for(new i=0; i<MAX_SLOTS; i++)
            {
                SetPlayerCheckpoint(i, vehx, vehy, vehz, ratio); // lemme see
                romeo[i]= 1;
                if(!IsPlayerInVehicle(i, SearchedVehicle))
                {
                    SetVehicleParamsForPlayer(SearchedVehicle, i, 1, 0);
                }
                else
                {
                    SetVehicleParamsForPlayer(SearchedVehicle, i, 0, 0);
                }
            }
            AllPlaySound(1139);
        }
    }
Reply
#2

BUMP TOPIC
Reply
#3

pawn Код:
public OnPlayerEnterVehicle(playerid,vehicleid)
{
if(vehicleid == 123) // Switch 123 to your vehicle ID
{
if(gTeam[playerid] == TEAM_COP) // or GetPlayerTeam
{
return SendClientMessage(playerid,COLOR,"You are cop. You must defend this vehicle from stealers!");
}
else
{
return 1;
}
}
Not tested, might work? :l
Ps:Sorry for identation
Reply
#4

It makes pawno crash
Reply
#5

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(vehicleid == 123) // Switch 123 to your vehicle ID
    {
        if(gTeam[playerid] == TEAM_COP) // or GetPlayerTeam
        {
            new Float:X, Float:Y, Float:Z;
            GetPlayerPos(playerid,X,Y,Z);
            SetPlayerPos(playerid,X+2,Y,Z);
            SendClientMessage(playerid,COLOR,"You are cop. You must defend this vehicle from stealers!");
            return 1;
        }
        else
        {
            return 1;
        }
    }
    return 1;
}
Test this one now.
Reply
#6

It works thank you, but i have a problem it gives me 1 warning here is my OnPlayerEnterVehicle :

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{

    if(vehicleid == 123) // Switch 123 to your vehicle ID
    {
        if(gTeam[playerid] == TEAM_COP) // or GetPlayerTeam
        {
            new Float:X, Float:Y, Float:Z;
            GetPlayerPos(playerid,X,Y,Z);
            SetPlayerPos(playerid,X+2,Y,Z);
            SendClientMessage(playerid,COLOR_GREY,"You are cop. You must defend this vehicle from stealers!");
            return 1;
        }
        else
        {
            return 1;
        }
    }
    return 1;

    if(GetVehicleModel(vehicleid) == 449){PutPlayerInVehicle(playerid, vehicleid, 0);} // Tram
    //if(GetVehicleModel(vehicleid) == 537){PutPlayerInVehicle(playerid, vehicleid, 0);} // Freight // There are no bugs with trains.
    //if(GetVehicleModel(vehicleid) == 538){PutPlayerInVehicle(playerid, vehicleid, 0);} // Streak // There are no bugs with trains.

    //if(GetVehicleModel(vehicleid) == 570){if(ispassenger == 1){PutPlayerInVehicle(playerid, vehicleid, ispassenger);}} // Streak Carriage // This public doesn't support Carriage's
    //if(GetVehicleModel(vehicleid) == 590){if(ispassenger == 1){PutPlayerInVehicle(playerid, vehicleid, ispassenger);}} // Freibox Carriage // This public doesn't support Carriage's

    if(GetVehicleModel(vehicleid) == 441){PutPlayerInVehicle(playerid, vehicleid, 0);} // RC-Bandit
    if(GetVehicleModel(vehicleid) == 464){PutPlayerInVehicle(playerid, vehicleid, 0);} // RC-Baron
    if(GetVehicleModel(vehicleid) == 465){PutPlayerInVehicle(playerid, vehicleid, 0);} // RC-Raider
    if(GetVehicleModel(vehicleid) == 501){PutPlayerInVehicle(playerid, vehicleid, 0);} // RC-Goblin
    if(GetVehicleModel(vehicleid) == 564){PutPlayerInVehicle(playerid, vehicleid, 0);} // RC-Tiger
    if(GetVehicleModel(vehicleid) == 594){PutPlayerInVehicle(playerid, vehicleid, 0);} // RC-Cam
    return 1;
}
And the warning is :
pawn Код:
D:\Games\GTA San Andreas\server\gamemodes\slrpg.pwn(13832) : warning 225: unreachable code
line 13832 is :
pawn Код:
if(GetVehicleModel(vehicleid) == 449){PutPlayerInVehicle(playerid, vehicleid, 0);} // Tram
Reply
#7

Quote:
Originally Posted by [Aka]Dragonu
Посмотреть сообщение
It works thank you, but i have a problem it gives me 1 warning here is my OnPlayerEnterVehicle :

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{

    if(vehicleid == 123) // Switch 123 to your vehicle ID
    {
        if(gTeam[playerid] == TEAM_COP) // or GetPlayerTeam
        {
            new Float:X, Float:Y, Float:Z;
            GetPlayerPos(playerid,X,Y,Z);
            SetPlayerPos(playerid,X+2,Y,Z);
            SendClientMessage(playerid,COLOR_GREY,"You are cop. You must defend this vehicle from stealers!");
            return 1;
        }
        else
        {
            return 1;
        }
    }
    return 1;

    if(GetVehicleModel(vehicleid) == 449){PutPlayerInVehicle(playerid, vehicleid, 0);} // Tram
    //if(GetVehicleModel(vehicleid) == 537){PutPlayerInVehicle(playerid, vehicleid, 0);} // Freight // There are no bugs with trains.
    //if(GetVehicleModel(vehicleid) == 538){PutPlayerInVehicle(playerid, vehicleid, 0);} // Streak // There are no bugs with trains.

    //if(GetVehicleModel(vehicleid) == 570){if(ispassenger == 1){PutPlayerInVehicle(playerid, vehicleid, ispassenger);}} // Streak Carriage // This public doesn't support Carriage's
    //if(GetVehicleModel(vehicleid) == 590){if(ispassenger == 1){PutPlayerInVehicle(playerid, vehicleid, ispassenger);}} // Freibox Carriage // This public doesn't support Carriage's

    if(GetVehicleModel(vehicleid) == 441){PutPlayerInVehicle(playerid, vehicleid, 0);} // RC-Bandit
    if(GetVehicleModel(vehicleid) == 464){PutPlayerInVehicle(playerid, vehicleid, 0);} // RC-Baron
    if(GetVehicleModel(vehicleid) == 465){PutPlayerInVehicle(playerid, vehicleid, 0);} // RC-Raider
    if(GetVehicleModel(vehicleid) == 501){PutPlayerInVehicle(playerid, vehicleid, 0);} // RC-Goblin
    if(GetVehicleModel(vehicleid) == 564){PutPlayerInVehicle(playerid, vehicleid, 0);} // RC-Tiger
    if(GetVehicleModel(vehicleid) == 594){PutPlayerInVehicle(playerid, vehicleid, 0);} // RC-Cam
    return 1;
}
And the warning is :
pawn Код:
D:\Games\GTA San Andreas\server\gamemodes\slrpg.pwn(13832) : warning 225: unreachable code
line 13832 is :
pawn Код:
if(GetVehicleModel(vehicleid) == 449){PutPlayerInVehicle(playerid, vehicleid, 0);} // Tram
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{

    if(vehicleid == 123) // Switch 123 to your vehicle ID
    {
        if(gTeam[playerid] == TEAM_COP) // or GetPlayerTeam
        {
            new Float:X, Float:Y, Float:Z;
            GetPlayerPos(playerid,X,Y,Z);
            SetPlayerPos(playerid,X+2,Y,Z);
            SendClientMessage(playerid,COLOR_GREY,"You are cop. You must defend this vehicle from stealers!");
            return 1;
        }
        else
        {
            return 1;
        }
    }

    if(GetVehicleModel(vehicleid) == 449){PutPlayerInVehicle(playerid, vehicleid, 0);} // Tram
    //if(GetVehicleModel(vehicleid) == 537){PutPlayerInVehicle(playerid, vehicleid, 0);} // Freight // There are no bugs with trains.
    //if(GetVehicleModel(vehicleid) == 538){PutPlayerInVehicle(playerid, vehicleid, 0);} // Streak // There are no bugs with trains.

    //if(GetVehicleModel(vehicleid) == 570){if(ispassenger == 1){PutPlayerInVehicle(playerid, vehicleid, ispassenger);}} // Streak Carriage // This public doesn't support Carriage's
    //if(GetVehicleModel(vehicleid) == 590){if(ispassenger == 1){PutPlayerInVehicle(playerid, vehicleid, ispassenger);}} // Freibox Carriage // This public doesn't support Carriage's

    if(GetVehicleModel(vehicleid) == 441){PutPlayerInVehicle(playerid, vehicleid, 0);} // RC-Bandit
    if(GetVehicleModel(vehicleid) == 464){PutPlayerInVehicle(playerid, vehicleid, 0);} // RC-Baron
    if(GetVehicleModel(vehicleid) == 465){PutPlayerInVehicle(playerid, vehicleid, 0);} // RC-Raider
    if(GetVehicleModel(vehicleid) == 501){PutPlayerInVehicle(playerid, vehicleid, 0);} // RC-Goblin
    if(GetVehicleModel(vehicleid) == 564){PutPlayerInVehicle(playerid, vehicleid, 0);} // RC-Tiger
    if(GetVehicleModel(vehicleid) == 594){PutPlayerInVehicle(playerid, vehicleid, 0);} // RC-Cam
    return 1;
}
PS: I don't think OnPlayerEnterVehicle is called when you try to enter RC vehicles.
Reply
#8

Ok it worked but i edit it and now i have 2 errors :

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(vehicleid == 123) // Switch 123 to your vehicle ID
    {
        if(gTeam[playerid] == TEAM_COP && PlayerInfo[playerid][pRank] == 1 || gTeam[playerid] == TEAM_ARMY && PlayerInfo[playerid][pRank] == 2)) // or GetPlayerTeam
        {
            new Float:X, Float:Y, Float:Z;
            GetPlayerPos(playerid,X,Y,Z);
            SetPlayerPos(playerid,X+2,Y,Z);
            SendClientMessage(playerid,COLOR_GREY,"You must defend this vehicle from stealers!");
            return 1;
        }
        else
        {
            return 1;
        }
  }
Errors : [pawn]D:\Games\GTA San Andreas\server\gamemodes\slrpg.pwn(13815) : error 029: invalid expression, assumed zero
D:\Games\GTA San Andreas\server\gamemodes\slrpg.pwn(13823) : warning 225: unreachable code
D:\Games\GTA San Andreas\server\gamemodes\slrpg.pwn(13823) : error 029: invalid expression, assumed zero
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Errors.

Lines :
pawn Код:
if(gTeam[playerid] == TEAM_COP && PlayerInfo[playerid][pRank] == 1 || gTeam[playerid] == TEAM_ARMY && PlayerInfo[playerid][pRank] == 2)) // or GetPlayerTeam
pawn Код:
else
Reply
#9

Any help ?
Reply
#10

Bump!!!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)