Saving system -
_Khaled_ - 04.09.2012
HEllo, I use Y_INI Saving system..
But I want to make it mode decent, like it saves IP for example.
pawn Код:
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Password",PlayerInfo[playerid][pPass]);
INI_Int("Score",PlayerInfo[playerid][pScore]);
INI_Int("Cash",PlayerInfo[playerid][pCash]);
INI_Int("AdminLevel",PlayerInfo[playerid][pAdminLevel]);
INI_Int("Kills",PlayerInfo[playerid][pKills]);
INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
INI_Int("Banned",PlayerInfo[playerid][pBanned]);
return 1;
}
stock UserPath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string,sizeof(string),PATH,playername);
return string;
}
stock udb_hash(buf[]) {
new length=strlen(buf);
new s1 = 1;
new s2 = 0;
new n;
for (n=0; n<length; n++)
{
s1 = (s1 + buf[n]) % 65521;
s2 = (s2 + s1) % 65521;
}
return (s2 << 16) + s1;
}
public OnPlayerDisconnect(playerid, reason)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"Player's Data");
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Score",GetPlayerScore(playerid));
INI_WriteInt(File,"AdminLevel",PlayerInfo[playerid][pAdminLevel]);
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_WriteInt(File,"Banned",PlayerInfo[playerid][pBanned]);
INI_Close(File);
I want it to save IP.
and in ban, I want it to ban the IP of ther player :\
pawn Код:
dcmd_ban(playerid,params[])
{
#pragma unused params
new pname[MAX_PLAYER_NAME];
new string[128];
new cmdreason[100];
new id;
if(sscanf(params,"us[100]",id,cmdreason))
{
SendClientMessage(playerid,COLOR_ERROR,"Usage: /ban (Player Name/ID) (Reason)");
return 1;
}
if(!IsPlayerConnected(id))
{
format(string,sizeof(string),"The player is not connected to the server");
SendClientMessage(playerid,COLOR_RED,string);
return 1;
}
GetPlayerName(id, pname, sizeof(pname));
format(string,sizeof(string),"***An Administrator has banned %s(%d) from the server. (Reason: %s)",pname,id,cmdreason);
SendClientMessageToAll(COLOR_PINK,string);
SetTimer("BanPlayer",700,0);*/
/*if(UserPath(playerid)); //This is a fail, I need the correct function to use it..
{
INI_WriteInt(pname(id)).("Banned",1);
}*/
return 1;
}
Re: Saving system -
ThePrograme - 04.09.2012
pawn Код:
CMD:banip(playerid,params[]) {
if (pInfo[playerid][pAdmin] >= 4) {
new PlayerName[MAX_PLAYER_NAME], ip[15];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
if(sscanf(params,"s",ip)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /banip <IP>");
format(szString, sizeof(szString), "banip %s", ip);
SendRconCommand(szString);
format(szString, sizeof(szString), "* You have successfully IP Banned: %s", ip);
SendClientMessage(playerid, COLOR_GREEN, szString);
format(szString, sizeof(szString), "reloadbans");
SendRconCommand(szString);
}
else {
return 0;
}
return 1;
}
CMD:unbanip(playerid,params[]) {
if (pInfo[playerid][pAdmin] >= 4) {
new PlayerName[MAX_PLAYER_NAME], ip[15];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
if(sscanf(params,"s",ip)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /unbanip <IP>");
format(szString, sizeof(szString), "unbanip %s", ip);
SendRconCommand(szString);
format(szString, sizeof(szString), "* You have successfully unbanned the IP: %s", ip);
SendClientMessage(playerid, COLOR_GREEN, szString);
format(szString, sizeof(szString), "reloadbans");
SendRconCommand(szString);
}
else {
return 0;
}
return 1;
}
Here this might help and for save IP i don't know how to do it sorry.You got to mae somethin like OnPlayerDisconnect in the command.
Re: Saving system -
_Khaled_ - 04.09.2012
Can you please show me how to save player's IP and a /getip command? :\
Re: Saving system -
ThePrograme - 04.09.2012
so you want this:
pawn Код:
CMD:ip(playerid, params[]) {
if (pInfo[playerid][pAdmin] >= 3 || IsPlayerAdmin(playerid)) {
new id;
if(sscanf(params, "i",id)) return SendClientMessage(playerid, COLOR_RED,"USAGE: /ip <playerid>");
if (!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected.");
if (IsPlayerConnected(id)) {
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
new GPlayerName[MAX_PLAYER_NAME];
GetPlayerName(id, GPlayerName, sizeof(GPlayerName));
new tmpIP[16];
GetPlayerIp(playerid,tmpIP,sizeof(tmpIP));
format(szString, sizeof(szString), "* %s's (%d) IP: %s", GPlayerName, id, tmpIP);
SendClientMessage(playerid, COLOR_GREEN, szString);
}
}
else {
return 0;
}
return 1;
}
Re: Saving system -
_Khaled_ - 06.09.2012
BUMP, still need to know how to save IP and ban the IP..
Re: Saving system -
Jermi - 06.09.2012
pawn Код:
CMD:banip(playerid, params[])
{
if(IsPlayerConnected(playerid)) {
new string[128], tmp[32];
if(sscanf(params, "s[32]", tmp)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /banip [ip]");
if(PlayerInfo[playerid][pAdmin] >= 3) {
AddBan(tmp);
format(string, sizeof(string), "AdmCmd: %s has banned IP:%s", GetPlayerNameEx(playerid), tmp);
ABroadCast(COLOR_LIGHTRED,string,2);
} else {
SendClientMessage(playerid, COLOR_GRAD2, " You are not authorized to use that command !");
}
}
return 1;
}
Also Make sure that you have the SSCANF UPDATE [0.3e update]
Re: Saving system -
_Khaled_ - 06.09.2012
I need to save the IP to the User INI.
Tried GetPlayerIP but failed, anyone? :/
Re: Saving system -
_Khaled_ - 07.09.2012
Another bump :/