[Tutorial] Making Steal Able Cars [Good one for TDM]
#1

Hello, Today i will teach you guys how to make Steal Able Cars.. its simple easy and fast..

First Step: Defining Teams

pawn Code:
#define TEAM_ONE 1
#define TEAM_TWO 2

new PlayerTeam[MAX_PLAYERS];//we will use this down
new car1;//team one car
new car2;//team two car
Second Step: Making Vehicles
You can use any editor for the Vehicles once u have the Vehicle code like i have

pawn Code:
AddStaticVehicleEx(470,-1632.75170898,1294.86474609,7.14550352,138.00000000,-1,-1,15);
Now goto " OnGameModeInt " or " OnFilterScriptInt "
and add the following :
pawn Code:
car1 = AddStaticVehicleEx(470,-1632.75170898,1294.86474609,7.14550352,138.00000000,-1,-1,15);
pawn Code:
car2 = AddStaticVehicleEx(447,-1690.72692871,1380.04211426,14.88139153,224.00000000,-1,-1,15);
Now we have added the Cars Successfully

Third Step: Entering Vehicles
You can use GameText For Player or u can also Use Textdraw or Even SendClientMessage to give a Message to the Player.

Goto " OnPlayerStateChange "

and write:
pawn Code:
new vehicleid;//Defining Vehicle id
    if(newstate == PLAYER_STATE_DRIVER)//checking that if the state is driver or not
    {
        vehicleid = GetPlayerVehicleID(playerid);
        if(gTeam[playerid] == TEAM_ONE && vehicleid == car2)//team one and Car 2
        {
            GameTextForPlayer(playerid, "Enemy Vehicle! ~g~Take it Back to your Spawn", 3000, 5);
            SetPlayerCheckpoint(playerid, 2241.1335,-1318.9760,23.9844, 7.0);
                    SendClientMessageToAll(playerid,-1,"Team One is trying to Steal Team Two's Car");

        }
else if(gTeam[playerid] == TEAM_ONE && vehicleid == car1)//Teams Vehicle
        {
            GameTextForPlayer(playerid, "You Need to Protect This From your Enemy", 3000, 5);
            RemovePlayerFromVehicle(playerid); // player out of vehicle
        }
else if(gTeam[playerid] == TEAM_TWO && vehicleid == car1)//team 2 and Car 1
        {
            GameTextForPlayer(playerid, "Enemy Vehicle! ~g~Take it Back to your Spawn", 3000, 5);
            SetPlayerCheckpoint(playerid, 2241.1335,-1318.9760,23.9844, 7.0);
                    SendClientMessageToAll(playerid,-1,"Team Two is trying to Steal Team One's Car");
else if(gTeam[playerid] == TEAM_TWO && vehicleid == car2)//team 2 car 2
        {
            GameTextForPlayer(playerid, "You Need to Protect This From your Enemy", 3000, 5);
            RemovePlayerFromVehicle(playerid); // player out of vehicle

        }
        }
    }
Last(4th) Step: Giving Rewards
After Reaching the Checkpoint Rewards for the Player:

pawn Code:
public OnPlayerEnterCheckpoint(playerid)
{
    new playervehicleid = GetPlayerVehicleID(playerid);//Playerid = GetPlayerVehicle ID Easier for me

    if(gTeam[playerid] == TEAM_ONE)//Getting that if the player is from Team One
    {
        if(playervehicleid == car2)//getting that if the car is car 2
        {
                SetPlayerScore(playerid, GetPlayerScore(playerid) + 5);//giving 5 score
                GameTextForAll("~g~Team ~w~One ~g~Captured the Vehicle!", 3000, 5);//telling everyone that Team one did it
                PlaySoundForAll(1185, 0.0, 0.0, 0.0);//playing a Sound for the Winners
                SetVehicleToRespawn(car2);//respawn the Vehicle
        }
    }
    else if(gTeam[playerid] == TEAM_TWO)//getting players team
    {
        if(playervehicleid == car1)//get that if the player is in car 1
        {
            SetPlayerScore(playerid, GetPlayerScore(playerid) + 5);//giving the score
            GameTextForAll("~r~Team ~w~Two ~g~wins!", 3000, 5);//Gametext for all that Team TWO Wins
            PlaySoundForAll(1185, 0.0, 0.0, 0.0);//sound for the winners
                GameTextForAll("~g~Team ~w~Two ~g~Captured the Vehicle!", 3000, 5);//telling everyone that Team Two did it
                SetVehicleToRespawn(car1);//respawn the Vehicle
        }
    }
    return 1;
}
Fixing the Error of PlayPlayerSound(sound)

pawn Code:
PlayPlayerSound(sound)
{
for (new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i)) PlayerPlaySound(i,sound,0,0,0);
}
}
You're Done Now!

Thanks For looking At My Tut
thanks to the guy who made Rivershell (took some ideas from it)

+Rep if u liked it
Reply
#2

Its not bad. But you should add more detail for starters -_- not just copy that or write that. anyway nice.
Reply
#3

First Tut?
anyway, nice.
keep up the good works.
Reply
#4

Needed explanation.Newbies would be confused.Nice besides that.
Reply
#5

Isn't this taken from barron.pwn of standard sa-mp game modes?
Reply
#6

Quote:
Originally Posted by AtItsMax
View Post
Isn't this taken from barron.pwn of standard sa-mp game modes?
haha lol no... its easy to make Steal Able Cars..
Reply
#7

Are you kidding?

You name this a tutorial??

Well,learn how to write a tutorial first you didn't explain anything you just say add this in blabla and this at blabla and your finished? why don't you just put this as a filterscript or something??
Reply
#8

i will not use this but nice
Reply
#9

i want to use it but when i code this and get in my game and bring the checkpoint to the base it crashes my game

do you know and can fix my prob
Reply
#10

PlaySoundForAll ? it gives me a error error 017: undefined symbol "PlaySoundForAll"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)