function LoadUser_data(playerid,name[],value[]) { INI_Int("Password",PlayerInfo[playerid][pPass]); INI_Int("Cash",PlayerInfo[playerid][pCash]); INI_Int("Admin",PlayerInfo[playerid][pAdmin]); INI_Int("Sex",PlayerInfo[playerid][pSex]); INI_Int("Age",PlayerInfo[playerid][pAge]); INI_Float("Pos_x",PlayerInfo[playerid][pPos_x]); INI_Float("Pos_y",PlayerInfo[playerid][pPos_y]); INI_Float("Pos_z",PlayerInfo[playerid][pPos_z]); INI_Int("Skin",PlayerInfo[playerid][pSkin]); INI_Int("Team",PlayerInfo[playerid][pTeam]); INI_Int("Accent",PlayerInfo[playerid][pAccent]); INI_Int("Account_Locked",PlayerInfo[playerid][pAccLock]); return 1; }
enum vInfo { vOwner, vID, vPlate } new VehicleInfo[MAX_PLAYERS][vInfo];
One way to do it is to save player's name using INI_String and later check it using strcmp.
// oops, dont know why I misunderstood the topic and thought its only to assign one veh to a player, sorry |
function LoadVehicles(vehid,name[],value[])
{
INI_String("Owner", VehicleInfo[vehid][vOwner], MAX_PLAYER_NAME);
INI_Int("ID",VehicleInfo[veid][vID]);
INI_String("Plate", VehicleInfo[vehid][vPlate], 10);
return 1;
}
Just a simple exemple
PHP код:
|
C:\Users\andrei\Desktop\Scripting SA-MP\Basic RP Script Scratch FIX\gamemodes\U1.pwn(1009) : error 001: expected token: ")", but found "[" C:\Users\andrei\Desktop\Scripting SA-MP\Basic RP Script Scratch FIX\gamemodes\U1.pwn(1009) : warning 215: expression has no effect C:\Users\andrei\Desktop\Scripting SA-MP\Basic RP Script Scratch FIX\gamemodes\U1.pwn(1009) : error 001: expected token: ";", but found "]" C:\Users\andrei\Desktop\Scripting SA-MP\Basic RP Script Scratch FIX\gamemodes\U1.pwn(1009) : error 029: invalid expression, assumed zero C:\Users\andrei\Desktop\Scripting SA-MP\Basic RP Script Scratch FIX\gamemodes\U1.pwn(1009) : fatal error 10
//Somewhere on your code put this, more likely at the top
#define VEH_PATH "%d.ini" //The path of the file
#define MAXPVEHS 100 //The maximum private vehicles
//This Function will help set a proper name for your data storing file, it will be named according to the vehicle ID the stored data belong
VehPth(vid){
new str[3];
format(str, sizeof(str), VEH_PATH, vid);
return str;
}
//A loop that will go thought all the files and create vehicles, this should be on OnGamemodeInIt/OnFilterScriptInIt
for(i=0;i<MAX_PVEHS;i++){
INI_ParseFile(VehPth(i), "VehicleLoad", .bExtra = true, .extra = i); //This will call the loading function to extract data
CreateVehicle(vehicletype, Float:x, Float:y, Float:z, Float:rotation, color1, color2, respawn_delay, addsiren=0);
SetVehicleNumberPlate(i, VehicleInfo[i][vPlate])
//The rest is up to you
}
//Data loading function
LoadVehicles(vehid,name[],value[])
{
INI_String("Owner", VehicleInfo[vehid][vOwner], MAX_PLAYER_NAME);
INI_Int("ID",VehicleInfo[veid][vID]);
INI_String("Plate", VehicleInfo[vehid][vPlate], 10);
return 1;
}
C:\Users\andrei\Desktop\Scripting SA-MP\Basic RP Script Scratch FIX\gamemodes\U1.pwn(704) : warning 213: tag mismatch C:\Users\andrei\Desktop\Scripting SA-MP\Basic RP Script Scratch FIX\gamemodes\U1.pwn(704) : warning 213: tag mismatch C:\Users\andrei\Desktop\Scripting SA-MP\Basic RP Script Scratch FIX\gamemodes\U1.pwn(704) : warning 213: tag mismatch C:\Users\andrei\Desktop\Scripting SA-MP\Basic RP Script Scratch FIX\gamemodes\U1.pwn(704) : warning 213: tag mismatch C:\Users\andrei\Desktop\Scripting SA-MP\Basic RP Script Scratch FIX\gamemodes\U1.pwn(1953) : warning 203: symbol is never used: "LoadVehicles" Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 5 Warnings.
CreateVehicle(vType, vPos_x, vPos_y, vPos_z, vRot, vColor1, vColor2, -1);
//To call LoadVehicles function, use this:
INI_ParseFile(VehPth(i), "VehicleLoad", .bExtra = true, .extra = i); //This will call the loading function to extract data
PHP код:
|
[data] Owner = Noone Type = 400 Plate = TEST Pos_x = 1451.7761 Pos_y = -1153.5676 Pos_z = 23.7988 Rot = 0.0000 Color1 = 3 Color2 = 5 RespawnDelay = 5