SA-MP Forums Archive
[Tutorial] Create a personnal car - 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)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] Create a personnal car (/showthread.php?tid=458082)



Create a personnal car - 1Geek - 14.08.2013

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



Re: Create a personnal car - verlaj - 15.08.2013

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


Re: Create a personnal car - Matnix - 15.08.2013

For the tele commands, you should use GetVehiculePos function.


Re : Re: Create a personnal car - 1Geek - 15.08.2013

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 !


Re : Re: Create a personnal car - 1Geek - 15.08.2013

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


Re: Create a personnal car - gtakillerIV - 15.08.2013

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


Re: Create a personnal car - 69ProFeSSioNaL69 - 19.08.2013

tnk so much


Re: Create a personnal car - radiobizza - 31.08.2013

Is my script.. Bizza is my name