SA-MP Forums Archive
[HELP]CAR MISSION - 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: [HELP]CAR MISSION (/showthread.php?tid=234452)



[HELP]CAR MISSION - [Aka]Dragonu - 03.03.2011

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



Re: [HELP]CAR MISSION - [Aka]Dragonu - 04.03.2011

BUMP TOPIC


Re: [HELP]CAR MISSION - Marricio - 04.03.2011

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


Re: [HELP]CAR MISSION - [Aka]Dragonu - 04.03.2011

It makes pawno crash


Re: [HELP]CAR MISSION - Marricio - 04.03.2011

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.


Re: [HELP]CAR MISSION - [Aka]Dragonu - 05.03.2011

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



Re: [HELP]CAR MISSION - Th3Angel - 05.03.2011

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.


Re: [HELP]CAR MISSION - [Aka]Dragonu - 05.03.2011

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



Re: [HELP]CAR MISSION - [Aka]Dragonu - 05.03.2011

Any help ?


Re: [HELP]CAR MISSION - [Aka]Dragonu - 29.08.2011

Bump!!!!