ich habs NICHT gedownloaded
[pwn]createPlayerCar(playerid,modelid,Float:x,Float:y,Float:z,Float:r)
{
for(new i=0; i<sizeof(cInfo); i++)
{
if(cInfo[i][id_x]!=0)continue;
cInfo[i][besitzer]=sInfo[playerid][db_id];
GetPlayerName(playerid,cInfo[i][besitzer],MAX_PLAYER_NAME);
cInfo[i][c_x]=x;
cInfo[i][c_y]=y;
cInfo[i][c_z]=z;
cInfo[i][c_r]=r;
cInfo[i][model]=modelid;
cInfo[i][kmstand] = 0;
cInfo[i][id_x] = CreateVehicle(modelid,x,y,z,r,000,000,-1);
new string[128],pIDname[MAX_PLAYER_NAME];
GetPlayerName(playerid,pIDname,sizeof(pIDname));
format(string,sizeof(string),"Das Auto NR[%i] wurde für %s erstellt",i,pIDname);
SendClientMessageToAll(RED,string);
saveCarToDB(playerid,i);
return 1;
}
return 1;
}
ocmd:cc(playerid,params[])
{
if(!isAdmin(playerid,4))return SendClientMessage(playerid,RED,"Du hast keine Rechte dafür!");
new mID,pID;
if(sscanf(params,"ui",pID,mID)) return SendClientMessage(playerid,RED,"INFO: /cc [playerid] [VEHICLE ID]");
if(mID <400 || mID > 611) return SendClientMessage(playerid,RED,"Ungültige ID!");
new Float:xc,Float:yc,Float:zc,Float:rc;
GetPlayerPos(pID,xc,yc,zc);
GetPlayerFacingAngle(pID,rc);
createPlayerCar(pID,mID,xc,yc,zc,rc);
return 1;
}
enum playerInfo{
eingeloggt,
level,
db_id,
fraktion,
rang,
alevel,
spawnchange,
PaydayTime,
Payday,
autoschein,
rollerschein,
geld,
adname,
pGesperrt,
premiumlevel,
premiumzeit[2],
premiumGivenBy[MAX_PLAYER_NAME],
premiumGivenTS,
premiumSys,
};
[/expander]
getFreeCarID()
{
for(new i=0; i<sizeof(cInfo); i++)
{
if(cInfo[i][id_x]==0)return i;
}
return 0;
}
public OnPlayerCarsLoad(playerid) //Autos laden ^^
{
new num_fields,num_rows;
cache_get_data(num_rows,num_fields,dbhandle);
if(!num_rows)return 1;
for(new i=0; i<num_rows; i++)
{
new id=getFreeCarID();
cInfo[id][model]=cache_get_field_content_int(i,"model",dbhandle);
cInfo[id][besitzer]=cache_get_field_content_int(i,"besitzer",dbhandle);
cInfo[id][c_x]=cache_get_field_content_float(i,"x",dbhandle);
cInfo[id][c_y]=cache_get_field_content_float(i,"y",dbhandle);
cInfo[id][c_z]=cache_get_field_content_float(i,"z",dbhandle);
cInfo[id][c_r]=cache_get_field_content_float(i,"r",dbhandle);
cInfo[id][db_id]=cache_get_field_content_int(i,"id",dbhandle);
cInfo[id][kmstand]=cache_get_field_content_float(i,"kmstand",dbhandle);
cInfo[id][id_x]=CreateVehicle(cInfo[id][model],cInfo[id][c_x],cInfo[id][c_y],cInfo[id][c_z],cInfo[id][c_r],-1,-1,-1);
}
return 1;
}
loadPlayerCars(playerid) //Autos laden Funktion
{
new query[128];
format(query,sizeof(query),"SELECT * FROM autos WHERE besitzer='%i'",sInfo[playerid][db_id]);
mysql_function_query(dbhandle,query,true,"OnPlayerCarsLoad","i",playerid);
return 1;
}[/expander][/expander]
[/expander]
[/expander]
Laden funktioniert nur speichern nicht
public OnPlayerDisconnect(playerid, reason)
{
for(new i=0; i<sizeof(cInfo); i++)
{
if(cInfo[i][id_x]==0) continue;
if(cInfo[i][besitzer]!=sInfo[playerid][db_id])continue;
GetVehiclePos(cInfo[i][id_x],cInfo[i][c_x],cInfo[i][c_y],cInfo[i][c_z]);
GetVehicleZAngle(cInfo[i][id_x],cInfo[i][c_r]);
new query[128];
format(query,sizeof(query),"UPDATE autos SET x='%f',y='%f',z='%f',r='%f',kmstand='%f' WHERE id='%i'",cInfo[i][c_x],cInfo[i][c_y],cInfo[i][c_z],cInfo[i][c_r],cInfo[i][kmstand],sInfo[playerid][db_id]);
mysql_function_query(dbhandle,query,false,"","");
DestroyVehicle(cInfo[i][id_x]);
cInfo[i][id_x]=0;
}