[Tutorial] Create a personnal car
#1

Hey guys today i'm going to show u how to make personal cars
Step 1 : Create a new pawno file and delete all content xD
Step 2 : Add at the top
Code:
#include <a_samp>
Step 3 : Under this write
Code:
new privatecars;
// You should have :
Code:
#include <a_samp> 

new privatecars;
Step 4 : Go to "OnGameModeInit ()" and put a single name space, after that a draw and add vehicle space and the position

Template :
Code:
privatecars = AddStaticVehicle(vmodel, Float X, Float Y, Float Z, Rotation, Colour 1, Colour 2)
Example :
Code:
privatecars = AddStaticVehicle(411, 248.2920000, -1801.4291000, 4.4594000, 0.0000000, 3, 3)
// You should have this :
Code:
public OnGameModeInit() 
{ 
        privatecars = AddStaticVehicle(411, 248.2920000, -1801.4291000, 4.4594000, 0.0000000, 3, 3) 
        return 1; 
}
// Now we going to make the vehicle personal
Step 5 : Now Move to public OnPlayerStateChange()
Step 6 : Write this :
Code:
1)public OnPlayerStateChange(playerid, newstate, oldstate) 
2){ 
3)    if(newstate == PLAYER_STATE_DRIVER && GetPlayerVehicleID(playerid) == privatecars) 
4)    { 
5)        new name[MAX_PLAYER_NAME]; 
6)        GetPlayerName(playerid, name, sizeof(name)); 
7)        if(strcmp(name, "", false)) 
8)        { 
9)            RemovePlayerFromVehicle(playerid); 
10)            SendClientMessage(playerid, 0x281aeb, "This vehicle doesn't belong to "); 
11)        } 
12)    } 
13)    return 1; 
}
Step 8 : At the ling 7 write the EXACT name (in samp) of the car owner

Code:
public OnPlayerStateChange(playerid, newstate, oldstate) 
{ 
    if(newstate == PLAYER_STATE_DRIVER && GetPlayerVehicleID(playerid) == privatecars) 
    { 
        new name[MAX_PLAYER_NAME]; 
        GetPlayerName(playerid, name, sizeof(name)); 
        if(strcmp(name, "1Geek", false)) 
        { 
            RemovePlayerFromVehicle(playerid); 
            SendClientMessage(playerid, 0x281aeb, "This vehicle doesn't belong to 1Geek"); 
        } 
    } 
    return 1; 
}
// FINAL CODE FOR YOU GUYS

Code:
#include <a_samp> 
new privatecars; 
public OnGameModeInit() 
{ 
    privatecars = AddStaticVehicle(411, 248.2920000, -1801.4291000, 4.4594000, 0.0000000, 3, 3); 
    return 1; 
} 
public OnPlayerStateChange(playerid, newstate, oldstate) 
{ 
    if(newstate == PLAYER_STATE_DRIVER && GetPlayerVehicleID(playerid) == privatecars) 
    { 
        new name[MAX_PLAYER_NAME]; 
        GetPlayerName(playerid, name, sizeof(name)); 
        if(strcmp(name, "Bizza", false)) 
        { 
            RemovePlayerFromVehicle(playerid); 
            SendClientMessage(playerid, 0x281aeb, "This vehicle doesn't belong to you"); 
        } 
    } 
    return 1; 
}
Then Press F5 or Compile and Enjoy your private car.

// You can make a teleport to this car >>

Write this @ OnPlayerCommandText

Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/pcar1", true))
    {
        SetPlayerPos(playerid, 248.2920000, -1801.4291000, 4.4594000);
        return 1;
    }
    return 0;
}
Hope i helped more than one
Reply
#2

please don't use [code] tag, instead of that try using [pawn] tag, it would be better, P.S tut seems to be fine, but if you could put some use of Y_ini and zcmd or stuff like that, then it would be better
Reply
#3

For the tele commands, you should use GetVehiculePos function.
Reply
#4

Quote:
Originally Posted by verlaj
View Post
please don't use [code] tag, instead of that try using [pawn] tag, it would be better, P.S tut seems to be fine, but if you could put some use of Y_ini and zcmd or stuff like that, then it would be better
Thanks for your comment !
Reply
#5

Quote:
Originally Posted by Matnix
View Post
For the tele commands, you should use GetVehiculePos function.
Yeah it's a possibility
Reply
#6

I really didn't see anything explained. Just copy this and paste it there.
Reply
#7

tnk so much
Reply
#8

Is my script.. Bizza is my name
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)