Jump to content

[PAWN] Tutorial 4 Carsystem MySQL


PresidenT AnaS
 Share

Recommended Posts

Hello This day we have work about Carsystem MySQL (Fahrzeuge erstellen)

ETAPES:

public OnGameModeInit()

{
SetGameModeText("MrMonat Tutorialmode");
AddPlayerClass(1,199.0846,-150.0331,1.5781,359.1443,WEAPON_MP5,500,0,0,0,0);
AddPlayerClass(2,199.0846,-150.0331,1.5781,359.1443,WEAPON_MP5,500,0,0,0,0);
AddPlayerClass(3,199.0846,-150.0331,1.5781,359.1443,WEAPON_MP5,500,0,0,0,0);
 
DisableInteriorEnterExits();
//Gebäude laden
for(new i=0; i<sizeof(bInfo); i++)
{
CreatePickup(1239,1,bInfo[b_x],bInfo[b_y],bInfo[b_z]);
Create3DTextLabel("Zum Betreten /enter",COLOR_RED,bInfo[b_x],bInfo[b_y],bInfo[b_z],10,0,1);
}
 
//Autos erstellen
AddStaticVehicle(560,214.1196,-141.3710,1.3052,1.6804,-1,-1); //Sultan
 
//Autohäuser laden
for(new i=0; i<sizeof(ahCars); i++)
{
ahCars[id_x]=AddStaticVehicle(ahCars[model],ahCars[c_x],ahCars[c_y],ahCars[c_z],ahCars[c_r],-1,-1);
}
 
//Timer
sekunden_timer = SetTimer("sekunde",1000,true);
 
//MySQL
dbhandle = mysql_connect(db_host,db_user,db_db,db_pass);
return 1;
}
 
public OnGameModeExit()
{
mysql_close(dbhandle);
return 1;
}
 
public sekunde()
{
printf("Timestamp: %i",gettime());
return 1;

 

 

 

public OnPlayerDisconnect(playerid, reason)
{
for(new i=0; i<sizeof(cInfo); i++)
{
if(cInfo[id_x]==0)continue;
if(cInfo[besitzer]!=sInfo[playerid][db_id])continue;
GetVehiclePos(cInfo[id_x],cInfo[c_x],cInfo[c_y],cInfo[c_z]);
GetVehicleZAngle(cInfo[id_x],cInfo[c_r]);
new query[256];
format(query,sizeof(query),"UPDATE autos SET x='%f',y='%f',z='%f',r='%f' WHERE id='%i'",cInfo[c_x],cInfo[c_y],cInfo[c_z],cInfo[c_r],cInfo[db_id]);
mysql_function_query(dbhandle,query,false,"","");
DestroyVehicle(cInfo[id_x]);
cInfo[id_x]=0;
}
savePlayer(playerid);
resetPlayer(playerid);
return 1;
}

 

 

Let's say:

{

new query[128];
format(query,sizeof(query),"INSERT INTO autos (besitzer,model,x,y,z,r) VALUES ('%i','%i','%f','%f','%f','%f')",sInfo[playerid][db_id],cInfo[carid][model],cInfo[carid][c_x],cInfo[carid][c_y],cInfo[carid][c_z],cInfo[carid][c_r]);
mysql_function_query(dbhandle,query,true,"carSavedToDB","i",carid);
return 1;
}

Thanks ƒor your time.Good Bye.

 

 

Edited by Cdorsu
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.