[Tutorial] How to make a Personal Car [NEW METHOD]
#1

Hello today i will teach u how to make a personal car for a player



#include <a_samp>
#include <zcmd>




#define R_Car "Radler" R_Car = Radler Car , Radler = Player name

To add the car u need to go in samp and type /save ... and after u will go in my documents/gta sa user/samp / savedpositions.txt
open and copy a text like this :


AddStaticVehicle(562,-1988.4819,275.2540,34.8352,235.3289,53,76);

Ok now after #define R_Car we will put this:

Code:
new rcar;
Now we go at the end of script and we make five stocks!

Code:
stock PlayerName(playerid) 
{
new Name[MAX_PLAYER_NAME] 
GetPlayerName(playerid, Name, 24);
return Name;
}
stock ERROR(playerid, EID) 
{
	new string[90];

	if(EID == 1)
	{
	    format(string, 90, "~w~NOT MY OWNER ~n~~r~%s", R_Car); 
	}
	return GameTextForPlayer(playerid, string, 5000, 4); 
}
stock Congratz(playerid) // This 2 stocks are optional but is very easy with these .
{
return SendClientMessage(playerid, 0xFF0000AA, "Congratz u spawned ur personal vehicle Radler!");
}
stock Sorry(playerid)
{
return SendClientMessage(playerid, 0xFF0000AA, "Sorry: U allready have a vehicle");
}
stock Car()
{
// This object are hold for personal car
new obiect192, obiect202, obiect212, obiect222, obiect232, obiect242,
	    obiect252, obiect262, obiect272, obiect282, obiect292, obiect302;
rcar = AddStaticVehicle(562,-1988.4819,275.2540,34.8352,235.3289,53,76); // Asta este masina si locul unde se va afla!

// Now we will create the holds //

	obiect192 = CreateObject(18647,0,0,-1000,0,0,0,100);	        obiect202 = CreateObject(18647,0,0,-1000,0,0,0,100);
	obiect212 = CreateObject(362,0,0,-1000,0,0,0,100);		obiect222 = CreateObject(362,0,0,-1000,0,0,0,100);
	obiect232 = CreateObject(359,0,0,-1000,0,0,0,100);		obiect242 = CreateObject(359,0,0,-1000,0,0,0,100);
	obiect252 = CreateObject(19419,0,0,-1000,0,0,0,100);	        obiect262 = CreateObject(18646,0,0,-1000,0,0,0,100);
	obiect272 = CreateObject(359,0,0,-1000,0,0,0,100);		obiect282 = CreateObject(359,0,0,-1000,0,0,0,100);
	obiect292 = CreateObject(18688,0,0,-1000,0,0,0,100);	        obiect302 = CreateObject(18688,0,0,-1000,0,0,0,100);


	AttachObjectToVehicle(obiect192, rcar, -0.824999,0.150000,-0.375000,0.000000,0.000000,0.000000);
	AttachObjectToVehicle(obiect202, rcar, 0.674999,0.150000,-0.375000,0.000000,0.000000,0.000000);
	AttachObjectToVehicle(obiect212, rcar, 0.749999,0.750000,0.299999,0.000001,2.700001,94.499977);
	AttachObjectToVehicle(obiect222, rcar, -0.600000,0.750000,0.299999,0.000001,2.700001,91.799980);
	AttachObjectToVehicle(obiect232, rcar, -0.449999,0.000000,0.749999,0.000000,0.000000,89.099983);
	AttachObjectToVehicle(obiect242, rcar, 0.524999,0.000000,0.749999,0.000000,0.000000,89.099983);
	AttachObjectToVehicle(obiect252, rcar, 0.000000,-1.950000,0.375000,0.000000,0.000000,-0.000002);
	AttachObjectToVehicle(obiect262, rcar, 0.000000,-0.375000,0.824999,0.000000,0.000000,0.000000);
	AttachObjectToVehicle(obiect272, rcar, -0.974999,-1.350000,0.300000,-45.900009,0.000000,89.099983);
	AttachObjectToVehicle(obiect282, rcar, 0.974999,-1.350000,0.300000,45.900005,0.000000,89.099983);
	AttachObjectToVehicle(obiect292, rcar, 0.749999,-1.424999,-2.025000,0.000000,0.000000,0.000000);
	AttachObjectToVehicle(obiect302, rcar, -1.200000,-1.424999,-2.025000,0.000000,0.000000,0.000000);
}
ATENTION : BEFORE U END WITH THE STOCKS U GO BACK TO public ongamemodeinit() and put this Car();

EXAMPLE:
Code:
public OnGameModeInit()
{
 Car();
return 1 ;
}
now we finish with the stocks we will go at the public OnPlayerStateChange(playerid, newstate, oldstate) to make

Code:
 public OnPlayerStateChange(playerid, newstate, oldstate)
{
   new vehicleid = GetPlayerVehicleID(playerid);
	//--------------------------------------------------------------------------
	if(newstate == PLAYER_STATE_DRIVER)
	{
	    if(vehicleid == rcar) // Check if car iz radler car
	    {
			if(strcmp(PlayerName(playerid), R_Car, true) == 0 || IsPlayerAdmin(playerid))  // if u want u can remove isplayeradmin ... this makes the rcon admin can use the car.
   			{
				return 1;
			}
			else
			{
				GetPlayerPos(playerid, x,y,z);	SetPlayerPos(playerid, x,y,z+5);
				return Eroare(playerid, 1);
			}
		}
          return 1 ;
}
We will go now at the command

Code:
CMD:mycar(playerid, params[])
{
	if(strcmp(PlayerName(playerid), R_Car, true) == 0)
	{
		if(!IsPlayerInAnyVehicle(playerid))
		{
		    GetPlayerPos(playerid, x,y,z);	SetVehiclePos(rcar, x+2,y+2,z);
		    PutPlayerInVehicle(playerid, rcar, 0);	  Congratz(playerid);
		}
		else Sorry(playerid);
	}
      return 1;
}
I will wait for ur opinion!
Regards!
Reply
#2

Ehm, No.
Reply
#3

What?
Reply
#4

Quote:
Originally Posted by JimmyCh
View Post
Ehm, No.
Ehm, No.
Sounds like something i would say...
Reply
#5

....
Reply
#6

Poorly Explained
Many Grammar Mistakes
And please use [PAWN] tags
Reply
#7

This is not a new method, you've just added some unnecessary stocks and as SsHady said..

Quote:
Originally Posted by SsHady
View Post
Poorly Explained
Many Grammar Mistakes
And please use [PAWN] tags
Reply
#8

ok ... sorry
Reply
#9

Horrible indentation. This is not a new method. I thought this was a tutorial on how to make a personal car, not attach objects as well.

Also, words like "u" to represent the real word and spelling errors everywhere..
Reply
#10

Not bad.

pawn Code:
new PrivateCar;
public OnGameModeInit()
{
    PrivateCar = AddStaticVehicle(411, X, Y, Z,Angle,COL1,COL2);
    return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER && GetPlayerVehicleID(playerid) == PrivateCar)
    {
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        if(strcmp(name, "NAME", false))
        {
            RemovePlayerFromVehicle(playerid);
            SendClientMessage(playerid,-1, "This is a private car.");
        }
    }
    return 1;
}
Here's how i'd do it. Less lines. Less useless stocks noobies won't know how to use, and its simple. I like simple

As for the stocks, wut? why make a stock called "Sorry"?

I dont get it.
pawn Code:
stock Sorry(playerid)
{
return SendClientMessage(playerid, 0xFF0000AA, "Sorry: U allready have a vehicle");
}
Just add the return in the command :S

See:
pawn Code:
CMD:mycar(playerid, params[])
{
    if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)return SendClientMessage(playerid,-1,"You need to be on foot!");
    if(strcmp(PlayerName(playerid), R_Car, true) == 0)
    {
        GetPlayerPos(playerid, x,y,z);  SetVehiclePos(rcar, x+2,y+2,z);
        PutPlayerInVehicle(playerid, rcar, 0);
        SendClientMessage(playerid,-1,"Car brought!");
    }
    return 1;
}
Reply
#11

Quote:
Originally Posted by Ady_Ro
View Post
ok ... sorry
You didnt fix any of the mistakes that have been pointed out. Just saying "sorry" doesnt make everything okay.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)