03.07.2013, 18:18
I have a problem, I've made a filterscipt that should save some PlayerInfos, but if script gets unloaded or server crashes all Infos get's restarted to 0 in /scriptfiles
here is some code
and the command I give Cards with
here is some code
pawn Код:
forward LoadPlayer(playerid);
public LoadPlayer(playerid)
{
new string3[128];
new playername2[MAX_PLAYER_NAME];
format(string3, sizeof(string3), "Army/%s.ini", playername2);
GetPlayerName(playerid, playername2, sizeof(playername2));
if(dini_Exists(string3))
{
PlayerInfo[playerid][Cgreen] = dini_Int(string3, "GreenCard");
PlayerInfo[playerid][Cred] = dini_Int(string3, "RedCard");
PlayerInfo[playerid][Cblue] = dini_Int(string3, "BlueCard");
PlayerInfo[playerid][Corange] = dini_Int(string3, "OrangeCard");
PlayerInfo[playerid][Call] = dini_Int(string3, "AllCards");
dini_IntSet(string3, "GreenCard",PlayerInfo[playerid][Cgreen]);
dini_IntSet(string3, "RedCard",PlayerInfo[playerid][Cred]);
dini_IntSet(string3, "BlueCard",PlayerInfo[playerid][Cblue]);
dini_IntSet(string3, "OrangeCard",PlayerInfo[playerid][Corange]);
dini_IntSet(string3, "AllCards",PlayerInfo[playerid][Call]);
}
return 1;
}
forward OnPlayerUpdateEx(playerid);
public OnPlayerUpdateEx(playerid)
{
if(IsPlayerConnected(playerid))
{
new string3[64];
new playername3[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername3, sizeof(playername3));
format(string3, sizeof(string3), "Army/%s.ini", playername3);
if(dini_Exists(string3))
{
dini_IntSet(string3, "GreenCard",PlayerInfo[playerid][Cgreen]);
dini_IntSet(string3, "RedCard",PlayerInfo[playerid][Cred]);
dini_IntSet(string3, "BlueCard",PlayerInfo[playerid][Cblue]);
dini_IntSet(string3, "OrangeCard",PlayerInfo[playerid][Corange]);
dini_IntSet(string3, "AllCards",PlayerInfo[playerid][Call]);
}
else
{
dini_Create(string3);
{
dini_IntSet(string3, "GreenCard",PlayerInfo[playerid][Cgreen]);
dini_IntSet(string3, "RedCard",PlayerInfo[playerid][Cred]);
dini_IntSet(string3, "BlueCard",PlayerInfo[playerid][Cblue]);
dini_IntSet(string3, "OrangeCard",PlayerInfo[playerid][Corange]);
dini_IntSet(string3, "AllCards",PlayerInfo[playerid][Call]);
}
}
}
}
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
new string3[64];
new playername3[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername3, sizeof(playername3));
format(string3, sizeof(string3), "Army/%s.ini", playername3);
if(!dini_Exists(string3))
{
}
else
{
dini_IntSet(string3, "GreenCard",PlayerInfo[playerid][Cgreen]);
dini_IntSet(string3, "RedCard",PlayerInfo[playerid][Cred]);
dini_IntSet(string3, "BlueCard",PlayerInfo[playerid][Cblue]);
dini_IntSet(string3, "OrangeCard",PlayerInfo[playerid][Corange]);
dini_IntSet(string3, "AllCards",PlayerInfo[playerid][Call]);
}
return 0;
}
pawn Код:
new cmd[30], params[30];
sscanf(cmdtext, "ss", cmd, params);
if(!strcmp(cmd, "/givecard"))
{
if(PlayerInfo[playerid][Alogined] == 1)
{
new player, level;
if(sscanf(params,"ud",player,level)) return SendClientMessage(playerid,COLOR_GREY,"USAGE: /givecard [playerid/PartOfName] [Card number]") && SendClientMessage(playerid,COLOR_GREY,"Cards : 1 ~ Green | 2 ~ Blue | 3 ~ Orange | 4 ~ Red | 5 ~ Full Acess |");
else if(!IsPlayerConnected(player))return SendClientMessage(playerid, COLOR_GREY, "Invalid Player ID/Name");
else if(level < 0 || level > 5) return SendClientMessage(playerid, COLOR_GREY,"* Only cards 1-5 Are allowed!");
else
{
new string[264];
new name[MAX_PLAYER_NAME+1];
new name1[MAX_PLAYER_NAME+1];
GetPlayerName(player, name, sizeof(name));
GetPlayerName(playerid, name1, sizeof(name));
if(level == 1)
{
format(string, sizeof(string), "%s has granted you green army keycard.", name1);
SendClientMessage(player, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "You've granted %s green army keycard.", name);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
PlayerInfo[player][Cgreen] = 1;
}
if(level == 2)
{
format(string, sizeof(string), "%s has granted you blue army keycard.", name1);
SendClientMessage(player, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "You've granted %s blue army keycard.", name);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
PlayerInfo[player][Cblue] = 1;
PlayerInfo[player][Cgreen] = 1;
PlayerInfo[player][Cred] = 1;
}
if(level == 3)
{
format(string, sizeof(string), "%s has granted you orange army keycard.", name1);
SendClientMessage(player, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "You've granted %s orange army keycard.", name);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
PlayerInfo[player][Corange] = 1;
PlayerInfo[player][Cred] = 1;
PlayerInfo[player][Cblue] = 1;
PlayerInfo[player][Cgreen] = 1;
}
if(level == 4)
{
format(string, sizeof(string), "%s has granted you red army keycard.", name1);
SendClientMessage(player, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "You've granted %s red army keycard.", name);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
PlayerInfo[player][Cred] = 1;
PlayerInfo[player][Cgreen] = 1;
}
if(level == 5)
{
format(string, sizeof(string), "%s has granted you full army access keycard.", name1);
SendClientMessage(player, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "You've granted %s full army access keycard.", name);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
PlayerInfo[player][Corange] = 1;
PlayerInfo[player][Cred] = 1;
PlayerInfo[player][Cblue] = 1;
PlayerInfo[player][Cgreen] = 1;
PlayerInfo[player][Call] = 1;
}
OnPlayerUpdateEx(player);
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You have to login in card maker to give out cards!") && ShowPlayerDialog(playerid, 50, DIALOG_STYLE_INPUT, "Army card maker login", "Type in the password.", "Confirm", "Cancel");
}
return 1;