new PlayerName[MAX_PLAYER_NAME], CarUName[32]; GetPlayerName(playerid, PlayerName, sizeof(PlayerName)); format(CarUName, sizeof(CarUName),"%s's%s", PlayerName, PlayerInfo[playerid][CarName]); //Will return Player'sCar
CarUName = CreateVehicle(playerid, PlayerInfo[playerid][CarID], PlayerInfo[playerid][CarX], PlayerInfo[playerid][CarY], PlayerInfo[playerid][CarZ], PlayerInfo[playerid][CarA], PlayerInfo[playerid][CarCol1], PlayerInfo[playerid][CarCol2], 0);
new carid = CreateVehicle(... //your things here)
INI_WriteInt(File,"CarID", carid);
CarInfo[carid][PlayerName]; //Change this
CarInfo[carid][CarName];//Change this
format(bla,sizeof(bla), "%s's %s", CarInfo[carid][PlayerName], CarInfo[carid][CarName]");
When a vehicle is bought, Save it to a .ini file which also stores the following two variables
Players Name (The one who bought it) Car Name (The cars name) Then add it to your current enum/loading/saving system. Now when you load it you could just do pawn Код:
pawn Код:
|
new hashpass[129], pCarName[64]; format(pCarName, sizeof(pCarName),"%s'%s", PlayerInfo[playerid][UserName], PlayerInfo[playerid][CarID]); WP_Hash(hashpass, sizeof(hashpass), inputtext); if(!strcmp(hashpass, PlayerInfo[playerid][Password])) { SendClientMessage(playerid, 0x00FF00FF,"You have succesfully logged in.\nWelcome back to a Bum's Life!"); (1011) pCarName = CreateVehicle(PlayerInfo[playerid][CarID], PlayerInfo[playerid][CarX], PlayerInfo[playerid][CarY], PlayerInfo[playerid][CarZ], PlayerInfo[playerid][CarA], PlayerInfo[playerid][CarCol1], PlayerInfo[playerid][CarCol2], 0); Finished = 1; }
(1011) : error 033: array must be indexed (variable "pCarName")
format(pCarName, sizeof(pCarName),"%s'%s", PlayerInfo[playerid][UserName], PlayerInfo[playerid][CarID]); //
stock GetVehicleName(vehicleid)
{
new String[150];
format(String,sizeof(String),"%s",VehicleNames[GetVehicleModel(vehicleid) - 400]);
return String;
}
new VehicleNames[][] =
{
"Landstalker", "Bravura", "Buffalo", "Linerunner", "Perrenial", "Sentinel",
"Dumper", "Firetruck", "Trashmaster", "Stretch", "Manana", "Infernus",
"Voodoo", "Pony", "Mule", "Cheetah", "Ambulance", "Leviathan", "Moonbeam",
"Esperanto", "Taxi", "Washington", "Bobcat", "Whoopee", "BF Injection",
"Hunter", "Premier", "Enforcer", "Securicar", "Banshee", "Predator", "Bus",
"Rhino", "Barracks", "Hotknife", "Trailer", "Previon", "Coach", "Cabbie",
"Stallion", "Rumpo", "RC Bandit", "Romero", "Packer", "Monster", "Admiral",
"Squalo", "Seasparrow", "Pizzaboy", "Tram", "Trailer", "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", "Cropduster", "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", "Hustler", "Intruder", "Primo",
"Cargobob", "Tampa", "Sunrise", "Merit", "Utility", "Nevada", "Yosemite",
"Windsor", "Monster", "Monster", "Uranus", "Jester", "Sultan", "Stratium",
"Elegy", "Raindance", "RC Tiger", "Flash", "Tahoma", "Savanna", "Bandito",
"Freight Flat", "Streak Carriage", "Kart", "Mower", "Dune", "Sweeper",
"Broadway", "Tornado", "AT-400", "DFT-30", "Huntley", "Stafford", "BF-400",
"News Van", "Tug", "Trailer", "Emperor", "Wayfarer", "Euros", "Hotdog", "Club",
"Freight Box", "Trailer", "Andromada", "Dodo", "RC Cam", "Launch", "Police Car",
"Police Car", "Police Car", "Police Ranger", "Picador", "S.W.A.T", "Alpha",
"Phoenix", "Glendale", "Sadler", "Luggage", "Luggage", "Stairs", "Boxville",
"Tiller", "Utility Trailer"
};
car= Dealership_AddVehicle(DealershipID, vModel, vPaint, vComponents, vX, vY, vZ, vR, C1, C2);
new string5[150];
format(string5,sizeof(string5),"%s's %s" , VehicleData[car][Owner],GetVehicleName(car));
new Text3D:ownedby = Create3DTextLabel(string5,0x00FF00FF,0.0,0.0,0.0,300.0,0,0);
pawn Код:
Why not use the GetVehicleName function? pawn Код:
This is what I have in my gm, might help you. pawn Код:
|
{ new hashpass[129], pCarName[64]; format(pCarName, sizeof(pCarName),"%s'%s", PlayerInfo[playerid][UserName], PlayerInfo[playerid][CarName]); WP_Hash(hashpass, sizeof(hashpass), inputtext); if(!strcmp(hashpass, PlayerInfo[playerid][Password])) { SendClientMessage(playerid, 0x00FF00FF,"You have succesfully logged in.\nWelcome back to a Bum's Life!"); pCarName = CreateVehicle(PlayerInfo[playerid][CarID], PlayerInfo[playerid][CarX], PlayerInfo[playerid][CarY], PlayerInfo[playerid][CarZ], PlayerInfo[playerid][CarA], PlayerInfo[playerid][CarCol1], PlayerInfo[playerid][CarCol2], 0); Finished = 1; } else { ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","{FF0000}You have entered an Incorrect password!\n{FFFFFF}Please enter your Correct password to login.","Login","Quit"); return 1; } return 1; } return 1;
enum PlayerData { UserName[MAX_PLAYER_NAME], Password[129], Float:PosX, Float:PosY, Float:PosZ, Float:PosA, Interior, VirtualWorld, Skin, Wallet, Bank, CarName[32], CarID, CarVW, CarI, Float:CarX, Float:CarY, Float:CarZ, Float:CarA, CarCol1, CarCol2 } new PlayerInfo[MAX_PLAYERS][PlayerData];
stock Save_Info(playerid) { GetPlayerPos(playerid, PlayerInfo[playerid][PosX], PlayerInfo[playerid][PosY], PlayerInfo[playerid][PosZ]); GetPlayerFacingAngle(playerid, PlayerInfo[playerid][PosA]); new INI:File = INI_Open(PPath(playerid)); INI_SetTag(File,"Player_Data"); INI_WriteFloat(File,"PosX", PlayerInfo[playerid][PosX]); INI_WriteFloat(File,"PosY", PlayerInfo[playerid][PosY]); INI_WriteFloat(File,"PosZ", PlayerInfo[playerid][PosZ]); INI_WriteFloat(File,"PosA", PlayerInfo[playerid][PosA]); INI_WriteInt(File,"VirtualWorld", GetPlayerVirtualWorld(playerid)); INI_WriteInt(File,"Interior", GetPlayerInterior(playerid)); INI_WriteInt(File,"Skin", GetPlayerSkin(playerid)); INI_WriteInt(File,"Wallet", PlayerInfo[playerid][Wallet]); INI_WriteInt(File,"Bank", PlayerInfo[playerid][Bank]); INI_WriteString(File,"CarName", PlayerInfo[playerid][CarName]); INI_WriteInt(File,"CarID", PlayerInfo[playerid][CarID]); INI_WriteInt(File,"CarVW", PlayerInfo[playerid][CarVW]); INI_WriteInt(File,"CarI", PlayerInfo[playerid][CarI]); INI_WriteFloat(File,"CarX", PlayerInfo[playerid][CarX]); INI_WriteFloat(File,"CarY", PlayerInfo[playerid][CarY]); INI_WriteFloat(File,"CarZ", PlayerInfo[playerid][CarZ]); INI_WriteFloat(File,"CarA", PlayerInfo[playerid][CarA]); INI_WriteInt(File,"CarColor1", PlayerInfo[playerid][CarCol1]); INI_WriteInt(File,"CarColor2", PlayerInfo[playerid][CarCol2]); INI_Close(File); }