[HELP] Saving Stuff
#1

I have a Police Script that I made.. but it's missing one thing. When I make someone a cop.. I want it to save to a scriptfile so that whenever they log back on.. or the server restarts, they will still be a cop. I would also like you to save your rank, so if they log off as Rank 8 Commissioner... they will log back on as Rank 8 Commissioner. Here is my script:

Quote:

#define FILTERSCRIPT
#include <a_samp>
#include <a_http>
#include <streamer>
#include <zcmd>
#include <gtazones>
#include <YSI\y_ini>
#include <sscanf2>
#include <dini>
#include <foreach>
#include "../include/gl_common.inc"

//Dialogs
#define DIALOG_SPAWNERMAIN 500
#define DIALOG_EQUIPMENT 501
#define DIALOG_PISTOLS 502
#define DIALOG_HEAVYWEPS 503
#define DIALOG_MELEE 504
#define DIALOG_CLOTHING 505

#define DISTANCE_BETWEEN_PLAYERS 5
#define COLOR_FAIL 0x00FFFFFF
#define COLOR_ERROR 0xFF0000FF
#define ROB_TIME 300000
#define SECONDS 10
#define TAZE_MS 400


//Colors
#define COLOR_GREY 0xAD9797FF
#define COLOR_GREEN 0x58AB54FF
#define COLOR_PURPLE 0x963A99FF
#define COLOR_YELLOW 0xEAFF03FF
#define COLOR_LIGHTBLUE 0x7ED5F2FF
#define COLOR_RED 0xFF0D1DFF
#define COLOR_WHITE 0xFFFFFFFF
#define COLOR_BLUE 0x5D00FFFF

#define NORMAL_PLAYER 0
#define COP_RANK_1 1
#define COP_RANK_2 2
#define COP_RANK_3 3
#define COP_RANK_4 4
#define COP_RANK_5 5
#define COP_RANK_6 6
#define COP_RANK_7 7
#define COP_RANK_8 8

#define COP_COLOR 0x375FFFFF
#define RED

#define DIALOG_TICKET 1
#define DIALOG_COP_HELP 2

new gTeam[MAX_PLAYERS];
new CopDuty[MAX_PLAYERS];
new JailTimer[MAX_PLAYERS];
new pTazed[MAX_PLAYERS];
new CountTimer[MAX_PLAYERS];
new Count;

enum Statistics
{
Arrests,
Tickets,
Suspected_Players,
TicketingCop[MAX_PLAYERS],
Jailed,
JailTime,
};
new Info[MAX_PLAYERS][Statistics];

forward TeamChat(string[]);
forward robtimer(id);
forward Jail1(player1);
forward Jail2(player1);
forward Jail3(player1);
forward JailPlayer(player1);
forward UnjailPlayer(player1);
forward Unfreeze(playerid);
forward Tazed(playerid);
forward CountDown(playerid);

public OnFilterScriptInit()
{

//Labels
Create3DTextLabel("LSPD Head Quarters", COLOR_WHITE, 1568.6295,-1689.9706,6.2188, 10.0, 0, 0);
Create3DTextLabel("Los Santos Police Department", COLOR_WHITE, 1554.0641,-1708.2268,6.2188, 10.0, 0, 0);
Create3DTextLabel("Los Santos Police Department", COLOR_WHITE, 1550.8027,-1697.4136,6.2188, 10.0, 0, 0);
Create3DTextLabel("Los Santos Police Department", COLOR_WHITE, 1532.0746,-1672.9426,6.2188, 10.0, 0, 0);
Create3DTextLabel("Los Santos Police Department", COLOR_WHITE, 1549.7200,-1656.8212,6.2188, 10.0, 0, 0);
return 1;
}

public OnFilterScriptExit()
{
return 1;
}

public OnPlayerConnect(playerid)
{
gTeam[playerid] = 0;
CopDuty[playerid] = 0;
Info[playerid][Jailed] = 0;
Info[playerid][JailTime] = 0;
new string[128], Playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, Playername, sizeof(Playername));
format(string, sizeof(string), "Police System/%s.ini", Playername);
if(fexist(string))
{
gTeam[playerid] = dini_Int(string, "Team");
Info[playerid][Jailed] = dini_Int(string, "Jailed");
Info[playerid][JailTime] = dini_Int(string, "Jail Timer");
SetPlayerWantedLevel(playerid, dini_Int(string, "Wanted Level"));
if((gTeam[playerid] <= && (gTeam[playerid] > 0))
{
Info[playerid][Arrests] = dini_Int(string, "Arrests");
Info[playerid][Tickets] = dini_Int(string, "Tickets");
Info[playerid][Suspected_Players] = dini_Int(string, "Suspected Players");
}
}
else
{
dini_Create(string);
dini_IntSet(string, "Team", gTeam[playerid]);
dini_IntSet(string, "Jailed", Info[playerid][Jailed]);
dini_IntSet(string, "Jail Timer", Info[playerid][JailTime]);
dini_IntSet(string, "Wanted Level", GetPlayerWantedLevel(playerid));
dini_IntSet(string, "Arrests", Info[playerid][Arrests]);
dini_IntSet(string, "Tickets", Info[playerid][Tickets]);
dini_IntSet(string, "Suspected Players", Info[playerid][Suspected_Players]);
}
if(Info[playerid][Jailed] == 1)
{
SendClientMessage(playerid, RED, "You can't escape your punishment, you are still in jail!");
SetTimerEx("JailPlayer",3000,0,"d",playerid);
JailTimer[playerid] = SetTimerEx("UnjailPlayer",Info[playerid][JailTime],0,"d",playerid);
}
return 0;
}

public OnPlayerDisconnect(playerid, reason)
{
new string[128], Playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, Playername, sizeof(Playername));
format(string, sizeof(string), "Police System/%s.ini", Playername);
if(fexist(string))
{
dini_IntSet(string, "Team", gTeam[playerid]);
dini_IntSet(string, "Jailed", Info[playerid][Jailed]);
dini_IntSet(string, "Jail Timer", Info[playerid][JailTime]);
dini_IntSet(string, "Wanted Level", GetPlayerWantedLevel(playerid));
if((gTeam[playerid] <= && (gTeam[playerid] > 0))
{
dini_IntSet(string, "Arrests", Info[playerid][Arrests]);
dini_IntSet(string, "Tickets", Info[playerid][Tickets]);
dini_IntSet(string, "Suspected Players", Info[playerid][Suspected_Players]);
}
}
else
{
dini_Create(string);
dini_IntSet(string, "Team", gTeam[playerid]);
dini_IntSet(string, "Jailed", Info[playerid][Jailed]);
dini_IntSet(string, "Jail Timer", Info[playerid][JailTime]);
dini_IntSet(string, "Wanted Level", GetPlayerWantedLevel(playerid));
if((gTeam[playerid] <= && (gTeam[playerid] > 0))
{
dini_IntSet(string, "Arrests", Info[playerid][Arrests]);
dini_IntSet(string, "Tickets", Info[playerid][Tickets]);
dini_IntSet(string, "Suspected Players", Info[playerid][Suspected_Players]);
}
}
if(CopDuty[playerid] == 1)
{
ResetPlayerWeapons(playerid);
CopDuty[playerid] = 0;
return 1;
}
return 1;
}

If anyone can do that, that would be great. REPS to anyone who writes a useful comment!
NOTE: I cut a piece of the end due to it being to long.. I'll add it as a comment.
Reply


Messages In This Thread
[HELP] Saving Stuff - by Ciarannn - 03.08.2014, 08:53
Re: [HELP] Saving Stuff - by Ciarannn - 03.08.2014, 08:55

Forum Jump:


Users browsing this thread: 1 Guest(s)