Hier alles, was mit dem thema zu tun hat
forward OnPlayerCarsLoaded(playerid);
public OnPlayerCarsLoaded(playerid)
{
new
idx,
result[256],
query[128];
new downer[MAX_PLAYER_NAME],dplate[20],Float:sx,Float:sy,Float:sz,model,colo1,colo2,dprice,dcar,iD,Float:sr;
format(result, 128, "SELECT * FROM `cars` WHERE `owner` = '%s'", SpielerName(playerid)); //owner = so wie owner eben in der DB heißt
mysql_query(query);
mysql_store_result();
while(mysql_fetch_row_format(result, "|"))
{
print(result);
sscanf(result, "p<|>is[16]ffffiiis[20]i",iD,downer,sx,sy,sz,sr,model,colo1,colo2,dplate,dprice);
Playercar[idx][owner] = downer;
Playercar[idx][plate] = dplate;
Playercar[idx][spawnx] = sx;
Playercar[idx][spawny] = sy;
Playercar[idx][spawnz] = sz;
Playercar[idx][spawnr] = sr;
Playercar[idx][modelid] = model;
Playercar[idx][c1] = colo1;
Playercar[idx][c2] = colo2;
Playercar[idx][price] = dprice;
Playercar[idx][car] = AddStaticVehicleEx(Playercar[idx][modelid],Playercar[idx][spawnx],Playercar[idx][spawny],Playercar[idx][spawnz],Playercar[idx] [spawnr],Playercar[idx][c1],Playercar[idx][c2],60);
idx++;
}
printf(" ||CAR: %s %i %f %f %f %f %i %i %i", downer,modelid,sx,sy,sz,sr,colo1,colo2,price);
mysql_free_result();
printf("[code=sql] Succesful. %i ausgelesen", idx); //
return 1;
}
ocmd:testcar(playerid, params[])
{
new vid,cw1,cw2,pricef;
if(sscanf(params,"iiii", vid,cw1,cw2,pricef))return SendClientMessage(playerid, -1, " /testcar <modelid> <c1> <c2> <price>");
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
CreateVehicle(vid,x,y,z,0,cw1,cw2,60);
return 1;
}
ocmd:savecar(playerid, params[])
{
#pragma unused params
new Float:x,Float:y,Float:z,Float:a,co1,co2,query[500];
new vehicleid = GetPlayerVehicleID(playerid);
new model = GetVehicleModel(vehicleid);
GetVehiclePos(vehicleid,x,y,z);
GetVehicleZAngle(vehicleid, a);
GetVehicleColor(vehicleid, co1, co2);
format(query, sizeof(query), "INSERT INTO `cars` (`owner`, `spawnx`, `spawny`, `spawnz`, `spawnr`, `modelid`, `c1`,`c2`) VALUES ('%s', '%f', '%f', '%f', '%f', '%d', '%d', '%d')", SpielerName(playerid), x, y, z, a,model, c1, c2);
mysql_query(query);
printf(" %s ", query);
RemovePlayerFromVehicle(playerid);
return 1;
}
enum cardata
{
id,
owner[MAX_PLAYER_NAME],
plate[20],
Float:spawnx,
Float:spawny,
Float:spawnz,
Float:spawnr,
modelid,
c1,
c2,
price,
car
}
new Playercar[MAX_CARS][cardata];
Cars werden beim login geladen
output
||CAR: 49 0.000000 0.000000 0.000000 0.000000 0 0 52
[20:53:27] [code=sql] Succesful. 0 ausgelesen