05.02.2017, 14:12
Hello Everyone i have a problem today i dont know how to fix it
The vehicle system is from WC-RP
Im Using WC-RP script
I need to make if player bought a car and leave his car will not disapper
How to make that?
HERE is the CODE:
OnPlayerConnect
LoadPLayervehicles(playerid):
I try to move it on GameModeInit and its not working
The vehicle system is from WC-RP
Im Using WC-RP script
I need to make if player bought a car and leave his car will not disapper
How to make that?
HERE is the CODE:
pawn Код:
LoadPlayerVehicles(playerid) {
query[0] = 0;//[512];
format(query,sizeof(query),"SELECT `id`,`model`,`colour1`,`colour2`,`locktype`,`locked`,`fuel`,`tirestatus`,`doorstatus`,`lightstatus`,`X`,`Y`,`Z`,`Angle`,`plate`,`hp`,`panelstatus`,`paintjob`,`flags`,`mileage`,`impoundprice`,`alarmsettings`,`comp0`,`comp1`,`comp2`,`comp3`,`comp4`,`comp5`,`comp6`,`comp7`,`comp8`,`comp9`,`comp10`,`comp11`,`comp12` FROM `playercars` WHERE `owner` = %d",GetPVarInt(playerid, "CharID"));
mysql_function_query(g_mysql_handle, query, true, "onPlayerLoadVehicles", "d",playerid);
}
public onPlayerLoadVehicles(playerid) {
new rows,fields;
new id_string[128],id;
new modelid, c1, c2;
new Float:X,Float:Y,Float:Z,Float:Angle;
cache_get_data(rows,fields);
for(new i=0;i<rows;i++) {
cache_get_row(i, 1, id_string);//model
modelid = strval(id_string);
cache_get_row(i, 2, id_string);//c1
c1 = strval(id_string);
cache_get_row(i, 3, id_string);//c2
c2 = strval(id_string);
cache_get_row(i, 10, id_string);//x
X = floatstr(id_string);
cache_get_row(i, 11, id_string);//y
Y = floatstr(id_string);
cache_get_row(i, 12, id_string);//z
Z = floatstr(id_string);
cache_get_row(i, 13, id_string);//angle
Angle = floatstr(id_string);
new carid = CreateVehicle(modelid,X,Y,Z,Angle,c1,c2,-1);
cache_get_row(i, 5, id_string);//lock
id = strval(id_string);
VehicleInfo[carid][EVLocked] = id;
cache_get_row(i, 4, id_string);//locktype
id = strval(id_string);
VehicleInfo[carid][EVLockType] = ELockType:id;
cache_get_row(i, 6, id_string);//fuel
id = strval(id_string);
VehicleInfo[carid][EVFuel] = id;
new tirestatus, doorstatus, lightstatus, panelstatus, Float:health;
cache_get_row(i, 16, id_string);//panel status
panelstatus = strval(id_string);
cache_get_row(i, 7, id_string);//tire status
tirestatus = strval(id_string);
cache_get_row(i, 8, id_string);//door status
doorstatus = strval(id_string);
cache_get_row(i, 9, id_string);//light status
lightstatus = strval(id_string);
cache_get_row(i, 15, id_string);//vehicle HP
health = floatstr(id_string);
//if(health < 250.0) health = 500.0;
if(health > 250.0) {
UpdateVehicleDamageStatus(carid, panelstatus, doorstatus, lightstatus, tirestatus);
SetVehicleHealth(carid, health);
}
cache_get_row(i, 17, id_string);//paintjob
new paintjob = strval(id_string);
if(vehicleHasPaintJob(carid)) {
VehicleInfo[carid][EVPaintjob] = paintjob;
}
vehOnLoadPaintJob(carid);
new componentid;
for(new x=22;(x-22)<13;x++) {
cache_get_row(i, x, id_string);
componentid = strval(id_string);
if(islegalcarmod(modelid, componentid))
AddVehicleComponent(carid,componentid);
}
new Float:MileAge;
cache_get_row(i, 19, id_string);//mileage
MileAge = floatstr(id_string);
VehicleInfo[carid][EVMileAge] = MileAge;
cache_get_row(i, 20, id_string);//Impound Price
VehicleInfo[carid][EVImpoundPrice] = strval(id_string);
cache_get_row(i, 21, id_string);//Alarm Settings
VehicleInfo[i][EAlarmFlags] = AlarmFlags:strval(id_string);
cache_get_row(i, 0, id_string);//SQL ID
id = strval(id_string);
VehicleInfo[carid][EVSQLID] = id;
cache_get_row(i, 18, id_string);
new EVehicleFlags:flags = EVehicleFlags:strval(id_string);
VehicleInfo[carid][EVFlags] = flags;
cache_get_row(i, 14, VehicleInfo[carid][EVPlate]);//vehicle HP
if(strlen(VehicleInfo[carid][EVPlate]) > 1) {
SetVehicleNumberPlate(carid, VehicleInfo[carid][EVPlate]);
}
VehicleInfo[carid][EVType] = EVehicleType_Owned;
VehicleInfo[carid][EVOwner] = playerid;
VehicleInfo[carid][EVColour][0] = c1;
VehicleInfo[carid][EVColour][1] = c2;
VehicleInfo[carid][EVRadioStation] = -1;
if(!IsACar(GetVehicleModel(carid))) {
VehicleInfo[carid][EVEngine] = 1;
} else {
VehicleInfo[carid][EVEngine] = 0;
}
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(carid,VehicleInfo[carid][EVEngine],lights,alarm,VehicleInfo[carid][EVLocked],bonnet,boot,objective);
loadTrunks(carid);
}
new slot = GetPVarInt(playerid, "LastPlayerCar");
if(slot != -1) {
new carid = findPlayerCar(playerid, slot);
if(carid != -1) {
PutPlayerInVehicleEx(playerid, carid, 0);
}
}
}
LoadPLayervehicles(playerid):
I try to move it on GameModeInit and its not working