19.10.2011, 11:10
I have an admin system and I can't save score/kills/deaths/money/skin after the login. So I added this when you spawn, automatically set money/skin/color except kills/deaths. They are bugged. Everytime I do /stats i have Kills: 2 Deaths: 0 and I have died 10 times.
This is the part that i save without register/login
And I want to change it to save all this to the admin system.
Here the admin system on register/login
Register and Login
I added this that it ask you on connect for password, but it ask password and then you aren't login and the players must /login password again.
Also, my dialogs bugged, I don't know if I have dialog id 2 in two different FS is problem, but I did /buyweapons and it says you password changed to Desert Eagle (500) ($1)
I want deleted all this and save all the above on the admin system.
Can anyone help me!
This is the part that i save without register/login
pawn Код:
enum PLAYER_DATA
{
Kills,
Deaths,
}
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
SendDeathMessage(INVALID_PLAYER_ID,playerid,201);//it works! i have tried! ;)
new file[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
//leader the name of your folder in scriptfiles
format(file, sizeof(file), "\\Leaders\\%s.ini", pname);
if(!dini_Exists(file))
dini_Create(file);
dini_IntSet(file, "skin", GetPlayerSkin(playerid));
dini_IntSet(file, "score", GetPlayerScore(playerid));
dini_IntSet(file, "color", GetPlayerColor(playerid));
dini_IntSet(file, "money", GetPlayerMoney(playerid));
dini_IntSet(file, "Kills", pDATA[ playerid ][ Kills ]);
dini_IntSet(file, "Deaths", pDATA[ playerid ][ Deaths ]);
KillTimer(timer);
return 1;
}
pawn Код:
public OnPlayerSpawn(playerid)
{
if(IsPlayerNPC(playerid)) { //Checks if the player that just spawned is an NPC.
new npcname[MAX_PLAYER_NAME];
//Getting the NPC's name.
GetPlayerName(playerid, npcname, sizeof(npcname));
//Checking if the NPC's name is Taxi_Driver
if(!strcmp(npcname, "Taxi_Driver", true)) {
//Putting the NPC into the vehicle we created for it.
PutPlayerInVehicle(playerid, Taxi_DriverVehicle, 0);
SetPlayerSkin(playerid,141);
SetPlayerColor(playerid,COLOR_YELLOW);
}
//Checking if the NPC's name is Taxi_Driver
if(!strcmp(npcname, "Harry_Potter", true)) {
//Putting the NPC into the vehicle we created for it.
PutPlayerInVehicle(playerid, Harry_PotterVehicle, 0);
SetPlayerSkin(playerid,147);
SetPlayerColor(playerid,COLOR_WHITE);
}
return 1;
}
SetPlayerInterior(playerid,0);
SetPlayerRandomSpawn(playerid);
GivePlayerWeapon(playerid, 24, 999);
GivePlayerWeapon(playerid, 26, 999);
GivePlayerWeapon(playerid, 21, 999);
GivePlayerMoney(playerid, 50000);
new file[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof(file), "\\Leaders\\%s.ini", pname);
if(dini_Exists(file)) {
SetTimerEx("SpawnSave", 10, false, "d", playerid);
}
return 1;
}
pawn Код:
forward SpawnSave(playerid);
public SpawnSave(playerid)
{
new file[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof(file), "\\Leaders\\%s.ini", pname);
SetPlayerSkin(playerid, dini_Int(file, "skin"));
SetPlayerScore(playerid, dini_Int(file, "score"));
SetPlayerColor(playerid, dini_Int(file, "color"));
SetPlayerMoney(playerid, dini_Int(file, "money"));
pDATA[ playerid ][ Kills ] = dini_Int(file, "Kills");
pDATA[ playerid ][ Deaths ] = dini_Int(file, "Deaths");
return 1;
}
Here the admin system on register/login
pawn Код:
enum PlayerData
{
Registered,
Loggedin,
Level,
Muted,
Jailed
}
new PData[MAX_PLAYERS][PlayerData];
pawn Код:
public OnPlayerConnect(playerid)
{
SCM(playerid, yellow, "Welcome. Type /register to register your account, or /login if you already have one.");
GetPlayerName(playerid, pname, sizeof(pname));
PData[playerid][Registered] = 0;
PData[playerid][Level] = 0;
PData[playerid][Loggedin] = 0;
PData[playerid][Jailed] = 0;
PData[playerid][Muted] = 0;
GetPlayerIp(playerid, pip, sizeof(pip));
format(str, sizeof(str), "%s.banned", pname);
if(dini_Int("banned-ips.txt", pip))
{
printf("%s (%s) detected as banned. Kicking...", pname, pip);
format(banstr1, sizeof(banstr1), "{FFFFFF}If you think you were banned for no reason, visit us at {FF0000}%s{FFFFFF} and post a ban appeal. Make sure you have a screenshot of this.", YOUR_SITE);
format(banstr, sizeof(banstr),"{FFFFFF}Ban information:\r\n{FF0000}Your name: {FFFFFF}%s\r\n{FF0000}Original banned name: {FFFFFF}%s\r\n{FF0000}Banned by: {FFFFFF}%s\r\n{FF0000}Ban time:{FFFFFF} %s\r\n{FF0000}Your IP: {FFFFFF}%s \r\n{FF0000}Reason:{FFFFFF} %s \r\n%s", pname, dini_Get(str, "ban-orgname"), dini_Get(str, "ban-admin"), dini_Get(str, "ban-date"), pip, dini_Get(str, "ban-reason"), banstr1);
ShowPlayerDialog(playerid, 1337, DIALOG_STYLE_MSGBOX, "{FF0000}You are banned from this server!", banstr, "Close", "");
Kick(playerid);
}
loginattempts[playerid] = 0;
return 1;
}
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
GetPlayerName(playerid, pname, sizeof(pname));
format(str, sizeof(str), "%s.user", pname);
if(dini_Exists(str) && PData[playerid][Loggedin])
{
dini_IntSet(str, "registered", 1);
dini_IntSet(str, "level", PData[playerid][Level]);
dini_IntSet(str, "muted", PData[playerid][Muted]);
dini_IntSet(str, "jailed", PData[playerid][Jailed]);
}
PData[playerid][Level] = 0;
KillTimer(mutetimer[playerid]);
KillTimer(jailtimer[playerid]);
loginattempts[playerid] = 0;
return 1;
}
pawn Код:
C(register)
{
new pass[128];
GetPlayerName(playerid, pname, sizeof(pname));
format(str, sizeof(str), "%s.user", pname);
if(dini_Exists(str)) return SCM(playerid, red, "ERROR: This nickname is already registered. Please reconnect with another nickname.");
else if(strlen(params) < 5) return SCM(playerid, red, "ERROR: Your password must be at least 5 characters long!");
else if(sscanf(params, "s[128]", pass)) return SCM(playerid, yellow, "SYNTAX: /register <password>");
WP_Hash(buf, sizeof(buf), pass);
dini_Create(str);
dini_IntSet(str, "registered", 1);
dini_IntSet(str, "level", 0);
dini_IntSet(str, "muted", PData[playerid][Muted]);
dini_IntSet(str, "jailed", PData[playerid][Jailed]);
dini_Set(str, "password", buf);
format(str2, sizeof(str2), "You have successfully registered your nickname with the password \"%s\" - please write it down incase you forget it.", pass);
SCM(playerid, green, str2);
SCM(playerid, green, "Don't worry, your password is saved hashed (whirlpool), and admins cannot see it. You have also been automatically logged in!");
PData[playerid][Loggedin] = 1;
PData[playerid][Registered] = 1;
dini_Set(str, "lastip", pip);
return 1;
}
C(login)
{
new pass[128];
GetPlayerName(playerid, pname, sizeof(pname));
format(str, sizeof(str), "%s.user", pname);
if(dini_Int(str, "registered") == 0) return SCM(playerid, red, "ERROR: This nickname isn't registered! Use /register first.");
else if(PData[playerid][Loggedin] == 1) return SCM(playerid, red, "ERROR: You are already logged in!");
else if(sscanf(params, "s[128]", pass)) return SCM(playerid, yellow, "SYNTAX: /login <password>");
WP_Hash(buf, sizeof(buf), pass);
if(strcmp(dini_Get(str, "password"), buf))
{
if(loginattempts[playerid] < 2)
{
SCM(playerid, red, "ERROR: Invalid password.");
loginattempts[playerid] ++;
}
else
{
SCM(playerid, red, "ERROR: Invalid password.");
format(str2, sizeof(str2), "Kicking %s for too many failed logins...", pname);
MessageAdmins(red, str2);
format(str3, sizeof(str3),"{FFFFFF}Kick information:\r\n{FF0000}Kicked by:{FFFFFF} SERVER\r\n{FF0000}Reason:{FFFFFF} Too many failed logins.\r\n{FFFFFF}Feel free to rejoin!");
ShowPlayerDialog(playerid, 13337, DIALOG_STYLE_MSGBOX, "{FF0000}You have been kicked.", str3, "Close", "");
loginattempts[playerid] = 0;
Kick(playerid);
}
}
else
{
PData[playerid][Muted] = dini_Int(str, "muted");
dini_IntSet(str, "registered", 1);
PData[playerid][Jailed] = dini_Int(str, "jailed");
GetPlayerIp(playerid, pip, sizeof(pip));
PData[playerid][Loggedin] = 1;
PData[playerid][Level] = dini_Int(str, "level");
PData[playerid][Registered] = 1;
format(str2, sizeof(str2), "You have been successfully logged in as level %d admin! Welcome back, %s!", PData[playerid][Level], pname);
SCM(playerid, green, str2);
GetPlayerIp(playerid, pip, sizeof(pip));
dini_Set(str, "lastip", pip);
}
return 1;
}
Also, my dialogs bugged, I don't know if I have dialog id 2 in two different FS is problem, but I did /buyweapons and it says you password changed to Desert Eagle (500) ($1)
I want deleted all this and save all the above on the admin system.
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 1) {
new name[MAX_PLAYER_NAME], file[256], string[128];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if(!response) return Kick(playerid);
if(!strlen(inputtext)) return
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Hi your not registered", "Welcome, your not a member,Input your PW below","Register","Kick Me");
dini_Create(file);
dini_IntSet(file, "Password", udb_hash(inputtext));
format(string, 128, "[SYSTEM]: You succesfully registered the nickname %s with password %s, you have been auto logged in.", name, inputtext);
SendClientMessage(playerid, 0xFF0000FF, string);
gPlayerLogged[playerid] = 1;
}
if(dialogid == 2) {
new name[MAX_PLAYER_NAME], file[256], string[128];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if(!response) return Kick(playerid);
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hi your registered,Welcome, your a member","Input your PW below","Register","Kick Me");
new tmp;
tmp = dini_Int(file, "Password");
if(udb_hash(inputtext) !=tmp) {
SendClientMessage(playerid, 0xFF0000FF, "Wrong Password");
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hi your registered", "Welcome, your not member,Input your PW below","Register","Kick Me");
}
else {
gPlayerLogged[playerid] = 1;
SendClientMessage(playerid, 0xFF0000FF, "[SYSTEM]: Successfully logged in!");
}
}
return 1;
}
pawn Код:
public OnPlayerConnect(playerid)
{
gPlayerLogged[playerid] = 0;
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
{
if(!dini_Exists(file)) {
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Hi your not registered", "Welcome, your not a member,Input your PW below","Register","Kick Me");
}
if(fexist(file)) {
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hi your registered", "Welcome, your a member,Input your PW below","Register","Kick Me");
}
}
return 1;
}