Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define FILTERSCRIPT
- #include <a_samp>
- #include <a_mysql>
- #define SQL_HOST "localhost"
- #define SQL_USER "root"
- #define SQL_PASS "toto91"
- #define SQL_DB "samp"
- new timer_gaz;
- public OnVehicleSpawn(vehicleid)
- {
- new query[200];
- format(query, sizeof(query), "DELETE FROM `car` WHERE `id` = %i LIMIT 1;", vehicleid);
- mysql_query(query);
- return 1;
- }
- public gaz(vehicleid) {
- new query[200];
- format(query, sizeof(query), "SELECT gas FROM `car` WHERE `id` = %i", vehicleid);
- mysql_query(query);
- mysql_store_result();
- new gas = mysql_fetch_int();
- mysql_free_result();
- printf("%i", gas);
- if(gas > 0) {
- if((gas-1) > 1) {
- gas = 0;
- new engine, lights, alarm, doors, bonnet, boot, objective;
- GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
- SetVehicleParamsEx(vehicleid,0,lights,alarm,doors,bonnet,boot,objective);
- new query1[200];
- format(query1, sizeof(query1), "UPDATE `car` SET `gas` = %i WHERE `id` = %i;", gas, vehicleid);
- mysql_query(query1);
- printf("%i", gas);
- }
- else {
- gas = gas-1;
- new query1[200];
- format(query1, sizeof(query1), "UPDATE `car` SET `gas` = %i WHERE `id` = %i;", gas, vehicleid);
- mysql_query(query1);
- printf("%i", gas);
- }
- }
- return 1;
- }
- forward gaz(vehicleid);
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- if(!ispassenger) {
- new query1[200];
- format(query1, sizeof(query1), "SELECT * FROM `car` WHERE `id` = %i", vehicleid);
- mysql_query(query1);
- mysql_store_result();
- new rows = mysql_num_rows();
- mysql_free_result();
- if(!rows) {
- new query2[200];
- format(query2, sizeof(query2), "INSERT INTO car (id, owner, gas) VALUES ('%i', '%i', 100)", vehicleid, playerid);
- mysql_query(query2);
- }
- else {
- timer_gaz = SetTimerEx("gaz", 2150, true, "i", vehicleid);
- }
- }
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid) {
- KillTimer(timer_gaz);
- return 1;
- }
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print("Car system by Moustachauve");
- print("--------------------------------------\n");
- mysql_debug(1);
- mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);
- mysql_query("TRUNCATE TABLE `car`");
- print("Table 'Car' videe avec succes !");
- return 1;
- }
- public OnFilterScriptExit()
- {
- mysql_query("TRUNCATE TABLE `car`");
- print("Table 'Car' videe avec succes !");
- mysql_close();
- print("Connexion avec la base terminé.");
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement