14.07.2013, 20:10
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:
Now we go at the end of script and we make five stocks!
ATENTION : BEFORE U END WITH THE STOCKS U GO BACK TO public ongamemodeinit() and put this Car();
EXAMPLE:
now we finish with the stocks we will go at the public OnPlayerStateChange(playerid, newstate, oldstate) to make
We will go now at the command
I will wait for ur opinion!
Regards!
#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;
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);
}
EXAMPLE:
Code:
public OnGameModeInit()
{
Car();
return 1 ;
}
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 ;
}
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;
}
Regards!


