question/help
#1

Hello everyone.
I am making vehicle system, I done basic things.
I just need little help, I need when player types /stats it shows his owned vehicles.

Question:
I must add at "enum PlayerInfo" something for vehicles if I wanted cars owned limit?
Reply
#2

This question wasn't really well explained.
In order to show the "owned" vehicles, you need a way you can save the owned vehicles, and then afterwards use the same way to read and show the owned vehicles.

First thing we need to know is, how do you assign a vehicle to a player? And do you save this to a DB or not? etc...
Try to fill out the question a bit more and we might be able to help you with the issue, and guide you what to do next
Reply
#3

Thats how I make player owner
PHP код:
VehicleInfo[newvehicle][vehicle] = CreateVehicle(carid532.3726,-1287.4926,17.2422,272.3125,0,0,32000); 
But how I'll know my car id and car model in /stats?
Reply
#4

okay I see.
To show model ID: "GetVehicleModel(VehicleInfo[...][...])" --> that will return the model of the vehicle id, read more here: https://sampwiki.blast.hk/wiki/GetVehicleModel

In order to show the car name, you will need something more:
Код:
new VehicleNames[212][] = {
	{"Landstalker"},{"Bravura"},{"Buffalo"},{"Linerunner"},{"Perrenial"},{"Sentinel"},{"Dumper"},
	{"Firetruck"},{"Trashmaster"},{"Stretch"},{"Manana"},{"Infernus"},{"Voodoo"},{"Pony"},{"Mule"},
	{"Cheetah"},{"Ambulance"},{"Leviathan"},{"Moonbeam"},{"Esperanto"},{"Taxi"},{"Washington"},
	{"Bobcat"},{"Mr Whoopee"},{"BF Injection"},{"Hunter"},{"Premier"},{"Enforcer"},{"Securicar"},
	{"Banshee"},{"Predator"},{"Bus"},{"Rhino"},{"Barracks"},{"Hotknife"},{"Trailer 1"},{"Previon"},
	{"Coach"},{"Cabbie"},{"Stallion"},{"Rumpo"},{"RC Bandit"},{"Romero"},{"Packer"},{"Monster"},
	{"Admiral"},{"Squalo"},{"Seasparrow"},{"Pizzaboy"},{"Tram"},{"Trailer 2"},{"Turismo"},
	{"Speeder"},{"Reefer"},{"Tropic"},{"Flatbed"},{"Yankee"},{"Caddy"},{"Solair"},{"Berkley's RC Van"},
	{"Skimmer"},{"PCJ-600"},{"Faggio"},{"Freeway"},{"RC Baron"},{"RC Raider"},{"Glendale"},{"Oceanic"},
	{"Sanchez"},{"Sparrow"},{"Patriot"},{"Quad"},{"Coastguard"},{"Dinghy"},{"Hermes"},{"Sabre"},
	{"Rustler"},{"ZR-350"},{"Walton"},{"Regina"},{"Comet"},{"BMX"},{"Burrito"},{"Camper"},{"Marquis"},
	{"Baggage"},{"Dozer"},{"Maverick"},{"News Chopper"},{"Rancher"},{"FBI Rancher"},{"Virgo"},{"Greenwood"},
	{"Jetmax"},{"Hotring"},{"Sandking"},{"Blista Compact"},{"Police Maverick"},{"Boxville"},{"Benson"},
	{"Mesa"},{"RC Goblin"},{"Hotring Racer A"},{"Hotring Racer B"},{"Bloodring Banger"},{"Rancher"},
	{"Super GT"},{"Elegant"},{"Journey"},{"Bike"},{"Mountain Bike"},{"Beagle"},{"Cropdust"},{"Stunt"},
	{"Tanker"}, {"Roadtrain"},{"Nebula"},{"Majestic"},{"Buccaneer"},{"Shamal"},{"Hydra"},{"FCR-900"},
	{"NRG-500"},{"HPV1000"},{"Cement Truck"},{"Tow Truck"},{"Fortune"},{"Cadrona"},{"FBI Truck"},
	{"Willard"},{"Forklift"},{"Tractor"},{"Combine"},{"Feltzer"},{"Remington"},{"Slamvan"},
	{"Blade"},{"Freight"},{"Streak"},{"Vortex"},{"Vincent"},{"Bullet"},{"Clover"},{"Sadler"},
	{"Firetruck LA"},{"Hustler"},{"Intruder"},{"Primo"},{"Cargobob"},{"Tampa"},{"Sunrise"},{"Merit"},
	{"Utility"},{"Nevada"},{"Yosemite"},{"Windsor"},{"Monster A"},{"Monster B"},{"Uranus"},{"Jester"},
	{"Sultan"},{"Stratum"},{"Elegy"},{"Raindance"},{"RC Tiger"},{"Flash"},{"Tahoma"},{"Savanna"},
	{"Bandito"},{"Freight Flat"},{"Streak Carriage"},{"Kart"},{"Mower"},{"Duneride"},{"Sweeper"},
	{"Broadway"},{"Tornado"},{"AT-400"},{"DFT-30"},{"Huntley"},{"Stafford"},{"BF-400"},{"Newsvan"},
	{"Tug"},{"Trailer 3"},{"Emperor"},{"Wayfarer"},{"Euros"},{"Hotdog"},{"Club"},{"Freight Carriage"},
	{"Trailer 3"},{"Andromada"},{"Dodo"},{"RC Cam"},{"Launch"},{"Police Car (LSPD)"},{"Police Car (SFPD)"},
	{"Police Car (LVPD)"},{"Police Ranger"},{"Picador"},{"S.W.A.T. Van"},{"Alpha"},{"Phoenix"},{"Glendale"},
	{"Sadler"},{"Luggage Trailer A"},{"Luggage Trailer B"},{"Stair Trailer"},{"Boxville"},{"Farm Plow"},
	{"Utility Trailer"}
};
Put that somewhere in your script, outside any callbacks and functions, pretty far up in your script.
then:

pawn Код:
VehicleNames[carmodel-400] //subtract 400 since the first car is modelid = 400.
Use the GetVehicleModel in order to find the correct name for the car, the way used above.
Please note the code above is copy-pasted from Luxurions LuxAdmin Admin system. https://sampforum.blast.hk/showthread.php?tid=120724
Reply
#5

Create an array for the player:
PHP код:
#define MAX_PLAYER_OWNED_VEHICLES 2 // edit to how much vehicles a player can own
#define DIALOG_PLAYER_VEHICLES 587 // change it if it collides
// global:
new Player_OwnedVehicles[MAX_PLAYER_OWNED_VEHICLES][MAX_PLAYERS];
// OnPlayerConnect:
for (new i!= MAX_PLAYER_OWNED_VEHICLES; ++i)
{
    
Player_OwnedVehicles[i][playerid] = INVALID_VEHICLE_ID;
}
// When creating the vehicle:
new boolfull true;
for (new 
i!= MAX_PLAYER_OWNED_VEHICLES; ++i)
{
    if (
GetVehicleModel(Player_OwnedVehicles[i][playerid])) continue; // vehicle exists
    
Player_OwnedVehicles[i][playerid] = CreateVehicle(...); // modify it
    
full false;
}
if (
full) return SendClientMessage(playerid, -1"No more slots available");
// when you want to show the vehicles:
new veh_string[50]; // if you increase the slots, make sure the string is enough
for (new i!= MAX_PLAYER_OWNED_VEHICLES; ++i)
{
    if (!
GetVehicleModel(Player_OwnedVehicles[i][playerid])) continue;
    
format(veh_stringsizeof (veh_string), "%s%i) Vehicle ID: %i & Model ID: %i\n"veh_string1Player_OwnedVehicles[i][playerid], GetVehicleModel(Player_OwnedVehicles[i][playerid]));
}
ShowPlayerDialog(playeridDIALOG_PLAYER_VEHICLESDIALOG_STYLE_MSGBOX"Owned Vehicles"veh_string"Close"""); 
Reply
#6

Look that my vehicle system
PHP код:
enum vehicleInfo
{
   
vehModel,
   
vehOwner[32],
   
vehicle,
   
Float:vehX,
   
Float:vehY,
   
Float:vehZ,
   
vehC1,
   
vehC2
}
new 
VehicleInfo[MAX_VEHS][vehicleInfo];
new 
newvehicle;
stock LoadVehs()
{
    for(new 
i=0;i<MAX_VEHS;i++)
    {
         new 
string[64];
         
format(stringsizeof(string), "/vehicles/%d.ini"i);
         if(
fexist(string))
         {
              
INI_ParseFile(string"LoadVehicles_%s", .bExtra true, .extra i);
              
VehicleInfo[i][vehicle] = CreateVehicle(VehicleInfo[i][vehModel], VehicleInfo[i][vehX], VehicleInfo[i][vehY], VehicleInfo[i][vehZ], VehicleInfo[i][vehC1], VehicleInfo[i][vehC2], 0, -1);
              
newvehicle=i+1;
         }
    }
    return 
1;
}
forward LoadVehicles_data(vehicleidname[], value[]);
public 
LoadVehicles_data(vehicleidname[], value[])
{
    
INI_Int("Model"VehicleInfo[vehicleid][vehModel]);
    
INI_String("Owner"VehicleInfo[vehicleid][vehOwner], MAX_PLAYER_NAME);
    
INI_Float("PosX"VehicleInfo[vehicleid][vehX]);
    
INI_Float("PosY"VehicleInfo[vehicleid][vehY]);
    
INI_Float("PosZ"VehicleInfo[vehicleid][vehZ]);
    
INI_Int("color1"VehicleInfo[vehicleid][vehC1]);
    
INI_Int("color2"VehicleInfo[vehicleid][vehC2]);
    return 
1;
}
stock SaveVehs()
{
    for(new 
i=0i<MAX_VEHSi++)
    {
         new 
string[64];
         
format(stringsizeof(string), "/vehicles/%d.ini"i);
         if(
fexist(string))
         {
              new 
INI:File=INI_Open(string);
              
GetVehiclePos(VehicleInfo[i][vehicle], VehicleInfo[i][vehX], VehicleInfo[i][vehY], VehicleInfo[i][vehZ]);
              
INI_WriteInt(File"Model"VehicleInfo[i][vehModel]);
              
INI_WriteString(File"Owner"VehicleInfo[i][vehOwner]);
              
INI_WriteFloat(File"PosX"VehicleInfo[i][vehX]);
              
INI_WriteFloat(File"PosY"VehicleInfo[i][vehY]);
              
INI_WriteFloat(File"PosZ"VehicleInfo[i][vehZ]);
              
INI_WriteInt(File"color1"VehicleInfo[i][vehC1]);
              
INI_WriteInt(File"color2"VehicleInfo[i][vehC2]);
              
INI_Close(File);
         }
    }

in raven's rp I saw this
PHP код:
PlayerInfo[playerid][pPcarkey
To make car limit, or to make Only the owner of the vehicle can use an command to his vehicle I need to add this to playerinfo?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)