SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 19/05/2019, 09:16 PM   #1
Uvais
Big Clucker
 
Uvais's Avatar
 
Join Date: Oct 2015
Posts: 170
Reputation: 13
Default Saving the Vehicles on Restart

My Restart Command:

PHP Code:
CMD:restart(playeridparams[])
{
    new 
time;

    if (
PlayerData[playerid][pAdmin] < 5)
        return 
SendErrorMessage(playerid"You don't have permission to use this command.");

    if (
g_ServerRestart)
    {
        
TextDrawHideForAll(gServerTextdraws[3]);

        
g_ServerRestart 0;
        
g_RestartTime 0;

        return 
SendClientMessageToAllEx(COLOR_LIGHTRED"[ADMIN]: %s has postponed the server restart."ReturnName(playerid0));
    }
    if (
sscanf(params"d"time))
        return 
SendSyntaxMessage(playerid"/restart [seconds]");

    if (
time || time 600)
        return 
SendErrorMessage(playerid"The specified seconds can't be below 3 or above 600.");
        
       
//foreach (new i : Player) {//////////////////////////////////
        //new carid = GetPlayerVehicleID(i);//////////////////////////////
        //Car_Save(carid);///////////////////////////////
        //SQL_SaveCharacter(i);/////////////////////////
    //}

    
TextDrawShowForAll(gServerTextdraws[3]);

    
g_ServerRestart 1;
    
g_RestartTime time;

    
SendClientMessageToAllEx(COLOR_LIGHTRED"[ADMIN]: %s has initiated a server restart in %d seconds."ReturnName(playerid0), time);
    return 
1;

Car_Save callback:

PHP Code:
Car_Save(carid)
{
    static
        
query[900];

    if (
CarData[carid][carVehicle] != INVALID_VEHICLE_ID)
    {
        for (new 
014++) {
            
CarData[carid][carMods][i] = GetVehicleComponentInSlot(CarData[carid][carVehicle], i);
        }
    }
    
format(querysizeof(query), "UPDATE `cars` SET `carModel` = '%d', `carOwner` = '%d', `carPosX` = '%.4f', `carPosY` = '%.4f', `carPosZ` = '%.4f', `carPosR` = '%.4f', `carColor1` = '%d', `carColor2` = '%d', `carPaintjob` = '%d', `carLocked` = '%d'",
        
CarData[carid][carModel],
        
CarData[carid][carOwner],
        
CarData[carid][carPos][0],
        
CarData[carid][carPos][1],
        
CarData[carid][carPos][2],
        
CarData[carid][carPos][3],
        
CarData[carid][carColor1],
        
CarData[carid][carColor2],
        
CarData[carid][carPaintjob],
        
CarData[carid][carLocked]
    );
    
format(querysizeof(query), "%s, `carMod1` = '%d', `carMod2` = '%d', `carMod3` = '%d', `carMod4` = '%d', `carMod5` = '%d', `carMod6` = '%d', `carMod7` = '%d', `carMod8` = '%d', `carMod9` = '%d', `carMod10` = '%d', `carMod11` = '%d', `carMod12` = '%d', `carMod13` = '%d', `carMod14` = '%d'",
        
query,
        
CarData[carid][carMods][0],
        
CarData[carid][carMods][1],
        
CarData[carid][carMods][2],
        
CarData[carid][carMods][3],
        
CarData[carid][carMods][4],
        
CarData[carid][carMods][5],
        
CarData[carid][carMods][6],
        
CarData[carid][carMods][7],
        
CarData[carid][carMods][8],
        
CarData[carid][carMods][9],
        
CarData[carid][carMods][10],
        
CarData[carid][carMods][11],
        
CarData[carid][carMods][12],
        
CarData[carid][carMods][13]
    );
    
format(querysizeof(query), "%s, `carImpounded` = '%d', `carImpoundPrice` = '%d', `carFaction` = '%d' , `carJob` = '%d' , `carSiren` = '%d', `carWeapon1` = '%d', `carWeapon2` = '%d', `carWeapon3` = '%d', `carWeapon4` = '%d', `carWeapon5` = '%d', `carAmmo1` = '%d', `carAmmo2` = '%d', `carAmmo3` = '%d', `carAmmo4` = '%d', `carAmmo5` = '%d' WHERE `carID` = '%d'",
        
query,
        
CarData[carid][carImpounded],
        
CarData[carid][carImpoundPrice],
        
CarData[carid][carFaction],
        
CarData[carid][carJob],
        
CarData[carid][carSiren],
        
CarData[carid][carWeapons][0],
        
CarData[carid][carWeapons][1],
        
CarData[carid][carWeapons][2],
        
CarData[carid][carWeapons][3],
        
CarData[carid][carWeapons][4],
        
CarData[carid][carAmmo][0],
        
CarData[carid][carAmmo][1],
        
CarData[carid][carAmmo][2],
        
CarData[carid][carAmmo][3],
        
CarData[carid][carAmmo][4],
        
CarData[carid][carID]
    );
    return 
mysql_tquery(g_iHandlequery);

Problem:

Whenever i restart the server, the player stats are saved whereas the vehicles are deleted. This only includes the personal vehicles which are created using "Create_Car". Any help will be appreciated, Thanks.
__________________
Uvais is offline   Reply With Quote
Old 20/05/2019, 11:43 AM   #2
Uvais
Big Clucker
 
Uvais's Avatar
 
Join Date: Oct 2015
Posts: 170
Reputation: 13
Default Re: Saving the Vehicles on Restart

bump
__________________
Uvais is offline   Reply With Quote
Old 21/05/2019, 05:49 PM   #3
d0minic
Little Clucker
 
d0minic's Avatar
 
Join Date: May 2019
Posts: 3
Reputation: 0
Default Re: Saving the Vehicles on Restart

Check OnGameModeInit for it.
d0minic is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[HELP] Auto Saving Vehicle Pos After Restart Rezkyta Scripting Help 1 30/11/2014 10:52 AM
Server not saving on restart? AphexCCFC Scripting Help 12 10/04/2014 11:04 AM
Saving weapons on server restart jackx3rx Scripting Help 2 12/03/2014 05:37 PM
Saving stats when server restart Face9000 Help Archive 5 16/12/2010 04:04 PM
Saving score on server restart: How? Jochemd Help Archive 3 19/03/2010 07:17 PM


All times are GMT. The time now is 12:38 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.