SA-MP Forums Archive
[Tutorial] Private cars - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [Tutorial] Private cars (/showthread.php?tid=406123)



Private cars - radiobizza - 09.01.2013

[Tutorial]How to create a private cars



In this tutorial I will show you how to create a personal car

P.S: No one can enter the vehicle. NOBODY

1) First create the unique name

PHP код:
#include <a_samp>
//the rest includes
new privatecars
2) Go to "OnGameModeInit ()" and put a single name space, after that a draw and add vehicle space and the position

PS: The car must position x, y, z, rx, ry, rz

PHP код:
public OnGameModeInit()
{
        
privatecars AddStaticVehicle(411248.2920000, -1801.42910004.45940000.000000033)
        return 
1;

P.S: the 2 to 3 are the colors of the vehicle

If you want to change it visit the site for more game

3)Now I will give you a script that will put it to "OnPlayerStateChange" and you change the name on car owner

PHP код:
1)public OnPlayerStateChange(playeridnewstateoldstate)
2){
3)    if(newstate == PLAYER_STATE_DRIVER && GetPlayerVehicleID(playerid) == privatecars)
4)    {
5)        new name[MAX_PLAYER_NAME];
6)        GetPlayerName(playeridnamesizeof(name));
7)        if(strcmp(name""false))
8)        {
9)            RemovePlayerFromVehicle(playerid);
10)            SendClientMessage(playerid0x281aeb"This vehicle doesn't belong to you");
11)        }
12)    }
13)    return 1;

Now turn 7 where are 2 quotes put the exact name of the owner

Now you should look like

PHP код:
public OnPlayerStateChange(playeridnewstateoldstate)
{
    if(
newstate == PLAYER_STATE_DRIVER && GetPlayerVehicleID(playerid) == privatecars)
    {
        new 
name[MAX_PLAYER_NAME];
        
GetPlayerName(playeridnamesizeof(name));
        if(
strcmp(name"Bizza"false))
        {
            
RemovePlayerFromVehicle(playerid);
            
SendClientMessage(playerid0x281aeb"This vehicle doesn't belong to you");
        }
    }
    return 
1;

Now all you have done would need to look like

PHP код:
#include <a_samp>
new privatecars;
public 
OnGameModeInit()
{
    
privatecars AddStaticVehicle(411248.2920000, -1801.42910004.45940000.000000033);
    return 
1;
}
public 
OnPlayerStateChange(playeridnewstateoldstate)
{
    if(
newstate == PLAYER_STATE_DRIVER && GetPlayerVehicleID(playerid) == privatecars)
    {
        new 
name[MAX_PLAYER_NAME];
        
GetPlayerName(playeridnamesizeof(name));
        if(
strcmp(name"Bizza"false))
        {
            
RemovePlayerFromVehicle(playerid);
            
SendClientMessage(playerid0x281aeb"This vehicle doesn't belong to you");
        }
    }
    return 
1;

I hope this tutorial helped you

Contact

YahooMessenger:radiobizza@yahoo.com

Skype:gabitza12321



My Work

[GM]The Godfather Highly Edited

[FS]Parking with lift LosSantos

[Tutorial]Private Cars



Re: Private cars - [RO]Five - 09.01.2013

Folositor.. multumim.

+REP


Re: Private cars - ajam123 - 09.01.2013

Can you make a small text? :3


Re: Private cars - _Mohit_ - 09.01.2013

good..it helped me a lot...tnx bro


Re: Private cars - radiobizza - 09.01.2013

Quote:
Originally Posted by ajam123
Посмотреть сообщение
Can you make a small text? :3
k man


Re: Private cars - Konstantinos - 09.01.2013

First of all, wrong section and you've explained nothing on the OnPlayerStateChange callback.


Re: Private cars - Flashbrot - 09.01.2013

ty i`ll test it later


Re: Private cars - DiReCt hIt - 09.01.2013

Nice Tutorial .


Re: Private cars - Red_Dragon. - 09.01.2013

Wrong section btw.. a tutorial MUST explain every single thing in it


Re: Private cars - DiGiTaL_AnGeL - 09.01.2013

You didn't explained anything in this tutorial. I have created one that could be understand by any newbie:https://sampforum.blast.hk/showthread.php?tid=406309