11.02.2012, 15:30
Hey guys, I am trying to an automatic savedata.
The command:
This is what I did:
Top of script, Under includes:
After public ongamemode..
and buttom of script:
The problem is the thing does not work, nothing saves every x5 seconds.
The command:
Код:
CMD:savedata(playerid, params[]) { //SetTimer("savedata", 1000, true); ( Ignore my scipter did that -_- ) SendClientMessageToAll(COLOR_RED, "(INFO) Server Data Succesfully Saved"); if(playerVariables[playerid][pAdminLevel] >= 5) { foreach(Player, x) { savePlayerData(x); } SendClientMessage(playerid, COLOR_YELLOW, "Player data saved."); for(new xh = 0; xh < MAX_HOUSES; xh++) { saveHouse(xh); } SendClientMessage(playerid, COLOR_YELLOW, "House data saved."); for(new xf = 0; xf < MAX_GROUPS; xf++) { saveGroup(xf); } SendClientMessage(playerid, COLOR_YELLOW, "Group data saved."); for(new xf = 0; xf < MAX_BUSINESSES; xf++) { saveBusiness(xf); } SendClientMessage(playerid, COLOR_YELLOW, "Business data saved."); for(new xf = 0; xf < MAX_ASSETS; xf++) { saveAsset(xf); } SendClientMessage(playerid, COLOR_YELLOW, "Server asset data saved."); } return 1; }
Top of script, Under includes:
Код:
//save data forward SaveData(playerid); //savedata
Код:
//save data SetTimer("SaveData", 5000, true); //save data
Код:
public SaveData() { SendClientMessageToAll(COLOR_RED, "(INFO) Server Data Succesfully Saved"); } SendClientMessage(playerid, COLOR_YELLOW, "Player data saved."); for(new xh = 0; xh < MAX_HOUSES; xh++) { saveHouse(xh); } SendClientMessage(playerid, COLOR_YELLOW, "House data saved."); for(new xf = 0; xf < MAX_GROUPS; xf++) { saveGroup(xf); } SendClientMessage(playerid, COLOR_YELLOW, "Group data saved."); for(new xf = 0; xf < MAX_BUSINESSES; xf++) { saveBusiness(xf); } SendClientMessage(playerid, COLOR_YELLOW, "Business data saved."); for(new xf = 0; xf < MAX_ASSETS; xf++) { saveAsset(xf); } SendClientMessage(playerid, COLOR_YELLOW, "Server asset data saved."); } return 1; }