01.01.2017, 14:59
(
Последний раз редактировалось Ramin; 02.01.2017 в 09:00.
)
PHP код:
new Old_Exp[MAX_PLAYERS];
new New_Exp[MAX_PLAYERS];
new My_Level[MAX_PLAYERS];
new My_ExpFNL[MAX_PLAYERS];
new Exp_string[50];
new Level_string[50];
new ExpFNL_string[50];
new levels,Nam[MAX_PLAYER_NAME],pname[MAX_PLAYER_NAME],stp[128],ID;
enum pInfo
{
pOld,
pOld_Exp,
pNew_Exp,
pMy_Level,
pMy_Rank,
pMy_ExpFNL,
pPass,
pCash,
pAdmin,
pKills,
pDeaths,
pScore,
pColor,
pSkin,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
stock LoginPlayer(playerid, passwd[])
{
new iniFile = ini_openFile(UserPath(playerid));
new bool:ret = false;
if ( iniFile >= 0 )
{
ini_getInteger(iniFile, "Password",PlayerInfo[playerid][pPass]);
if(udb_hash(passwd) == PlayerInfo[playerid][pPass])
{
ini_getInteger(iniFile, "Cash", PlayerInfo[playerid][pCash]);
ini_getInteger(iniFile, "Admin", PlayerInfo[playerid][pAdmin]);
ini_getInteger(iniFile, "Kills", PlayerInfo[playerid][pKills]);
ini_getInteger(iniFile, "Deaths", PlayerInfo[playerid][pDeaths]);
ini_getInteger(iniFile, "Score", PlayerInfo[playerid][pScore]);
ini_getInteger(iniFile, "Color", PlayerInfo[playerid][pColor]);
ini_getInteger(iniFile, "Skin", PlayerInfo[playerid][pSkin]);
ini_getInteger(iniFile, "Old", PlayerInfo[playerid][pOld]);
ini_getInteger(iniFile, "Old_Exp", PlayerInfo[playerid][pOld_Exp]);
ini_getInteger(iniFile, "New_Exp", PlayerInfo[playerid][pNew_Exp]);
ini_getInteger(iniFile, "My_Level", PlayerInfo[playerid][pMy_Level]);
ini_getInteger(iniFile, "pMy_Rank", PlayerInfo[playerid][pMy_Rank]);
ini_getInteger(iniFile, "My_ExpFNL", PlayerInfo[playerid][pMy_ExpFNL]);
ret = true;
} else ret = false;
ini_closeFile(iniFile);
}
return ret;
}
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 OnPlayerConnect(playerid)
{
format(Exp_string, sizeof(Exp_string), "Exp: %d/%d", New_Exp[playerid], Old_Exp[playerid]);
Exp[playerid] = TextDrawCreate(484.000000, 98.559997, "Exp 0/120");
TextDrawLetterSize(Exp[playerid], 0.345998, 1.413333);
TextDrawAlignment(Exp[playerid], 1);
TextDrawColor(Exp[playerid], -2139094785);
TextDrawSetShadow(Exp[playerid], 0);
TextDrawSetOutline(Exp[playerid], 1);
TextDrawBackgroundColor(Exp[playerid], 51);
TextDrawFont(Exp[playerid], 1);
TextDrawSetProportional(Exp[playerid], 1);
format(Level_string, sizeof(Level_string), "Level: %d Rank: Beginner", My_Level[playerid]);
Rank[playerid] = TextDrawCreate(483.999877, 113.493309, "Level: 0 Rank: Beginner");
TextDrawLetterSize(Rank[playerid], 0.353999, 1.450666);
TextDrawAlignment(Rank[playerid], 1);
TextDrawColor(Rank[playerid], -2139094785);
TextDrawSetShadow(Rank[playerid], 0);
TextDrawSetOutline(Rank[playerid], 1);
TextDrawBackgroundColor(Rank[playerid], 51);
TextDrawFont(Rank[playerid], 1);
TextDrawSetProportional(Rank[playerid], 1);
format(ExpFNL_string, sizeof(ExpFNL_string), "Exp For Next Level: %d", My_ExpFNL[playerid]);
ExpFNL[playerid] = TextDrawCreate(472.000000, 126.186546, "Exp For Next Level: 120");
TextDrawLetterSize(ExpFNL[playerid], 0.373999, 1.383466);
TextDrawAlignment(ExpFNL[playerid], 1);
TextDrawColor(ExpFNL[playerid], -2139094785);
TextDrawSetShadow(ExpFNL[playerid], 0);
TextDrawSetOutline(ExpFNL[playerid], 1);
TextDrawBackgroundColor(ExpFNL[playerid], 51);
TextDrawFont(ExpFNL[playerid], 1);
TextDrawSetProportional(ExpFNL[playerid], 1);
TextDrawShowForPlayer(playerid, Exp[playerid]);
TextDrawShowForPlayer(playerid, Rank[playerid]);
TextDrawShowForPlayer(playerid, ExpFNL[playerid]);
if(fexist(UserPath(playerid)))
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new iniFile = ini_openFile(UserPath(playerid));
if ( iniFile >= 0 )
{
ini_setInteger(iniFile, "Cash",GetPlayerMoney(playerid));
ini_setInteger(iniFile, "Admin",PlayerInfo[playerid][pAdmin]);
ini_setInteger(iniFile, "Old",PlayerInfo[playerid][pOld]);
ini_setInteger(iniFile, "Kills",PlayerInfo[playerid][pKills]);
ini_setInteger(iniFile, "Deaths",PlayerInfo[playerid][pDeaths]);
ini_setInteger(iniFile, "Old_Exp",PlayerInfo[playerid][pOld_Exp]);
ini_setInteger(iniFile, "New_Exp",PlayerInfo[playerid][pNew_Exp]);
ini_setInteger(iniFile, "My_Level",PlayerInfo[playerid][pMy_Level]);
ini_setInteger(iniFile, "pMy_Rank",PlayerInfo[playerid][pMy_Rank]);
ini_setInteger(iniFile, "My_ExpFNL",PlayerInfo[playerid][pMy_ExpFNL]);
ini_setInteger(iniFile, "Score",GetPlayerScore(playerid));
ini_setInteger(iniFile, "Color",GetPlayerColor(playerid));
ini_setInteger(iniFile, "Skin",GetPlayerSkin(playerid));
ini_closeFile(iniFile);
}
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid != INVALID_PLAYER_ID)
{
GivePlayerMoney(playerid,-GetPlayerMoney(playerid)/2);
PlayerInfo[killerid][pKills] += 1;
PlayerInfo[killerid][pScore] += 1;
SetPlayerScore(killerid, PlayerInfo[killerid][pScore]);
New_Exp[killerid] += 90;
New_Exp[playerid] -= 90;
if(New_Exp[playerid] < 0)
{
New_Exp[playerid] = 0;
}
if(New_Exp[killerid] >= 120 || 120 >= 380)
{
Old_Exp[killerid] = 380;
My_Level[killerid] = 1;
SendClientMessage(killerid,COLOR_YELLOW,"New Level = 1");
}
if(New_Exp[killerid] >= 380 || 380 >= 900)
{
Old_Exp[killerid] = 900;
My_Level[killerid] = 2;
SendClientMessage(killerid,COLOR_YELLOW,"New Level = 2");
}
if(New_Exp[killerid] >= 900 || 900 >= 1680)
{
Old_Exp[killerid] = 1680;
My_Level[killerid] = 3;
SendClientMessage(killerid,COLOR_YELLOW,"New Level = 3");
}
if(New_Exp[killerid] >= 1680 || 1680 >= 2720)
{
Old_Exp[killerid] = 2720;
My_Level[killerid] = 4;
SendClientMessage(killerid,COLOR_YELLOW,"New Level = 4");
}
if(New_Exp[killerid] >= 2720 || 2720 >= 4020)
{
Old_Exp[killerid] = 4020;
My_Level[killerid] = 5;
SendClientMessage(killerid,COLOR_YELLOW,"New Level = 5");
}
My_ExpFNL[playerid] = Old_Exp[playerid] - New_Exp[playerid];
My_ExpFNL[killerid] = Old_Exp[killerid] - New_Exp[killerid];
format(Exp_string, sizeof(Exp_string), "Exp: %d/%d", New_Exp[killerid], Old_Exp[killerid]);
format(Level_string, sizeof(Level_string), "Level: %d Rank: Beginner", My_Level[killerid]);
format(ExpFNL_string, sizeof(ExpFNL_string), "Exp For Next Level: %d", My_ExpFNL[killerid]);
TextDrawSetString(Exp[killerid], Exp_string);
TextDrawShowForPlayer(killerid, Exp[killerid]);
TextDrawSetString(Rank[killerid], Level_string);
TextDrawShowForPlayer(killerid, Rank[killerid]);
TextDrawSetString(ExpFNL[killerid], ExpFNL_string);
TextDrawShowForPlayer(killerid, ExpFNL[killerid]);
format(Exp_string, sizeof(Exp_string), "Exp: %d/%d", New_Exp[playerid], Old_Exp[playerid]);
format(Level_string, sizeof(Level_string), "Level: %d Rank: Beginner", My_Level[playerid]);
format(ExpFNL_string, sizeof(ExpFNL_string), "Exp For Next Level: %d", My_ExpFNL[playerid]);
TextDrawSetString(Exp[playerid], Exp_string);
TextDrawShowForPlayer(playerid, Exp[playerid]);
TextDrawSetString(Rank[playerid], Level_string);
TextDrawShowForPlayer(playerid, Rank[playerid]);
TextDrawSetString(ExpFNL[playerid], ExpFNL_string);
TextDrawShowForPlayer(playerid, ExpFNL[playerid]);
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
new iniFile = ini_createFile(UserPath(playerid));
if ( iniFile < 0 )
iniFile = ini_openFile(UserPath(playerid));
if ( iniFile >= 0 )
{
ini_setInteger(iniFile, "Password",udb_hash(inputtext));
ini_setInteger(iniFile, "Cash",5000);
ini_setInteger(iniFile, "Admin",0);
ini_setInteger(iniFile, "Kills",0);
ini_setInteger(iniFile, "Deaths",0);
ini_setInteger(iniFile, "Score",0);
ini_setInteger(iniFile, "Color",-1);
ini_setInteger(iniFile, "Skin",0);
ini_setInteger(iniFile, "Old",0);
ini_setInteger(iniFile, "Old_Exp",0);
ini_setInteger(iniFile, "New_Exp",0);
ini_setInteger(iniFile, "My_Level",0);
ini_setInteger(iniFile, "pMy_Rank",0);
ini_setInteger(iniFile, "My_ExpFNL",0);
ini_closeFile(iniFile);
}
PlayerInfo[playerid][pOld] = 0;
PlayerInfo[playerid][pOld_Exp] = 0;
PlayerInfo[playerid][pNew_Exp] = 0;
PlayerInfo[playerid][pMy_Level] = 0;
PlayerInfo[playerid][pMy_Rank] = 0;
PlayerInfo[playerid][pMy_ExpFNL] = 0;
PlayerInfo[playerid][pAdmin] = 0;
PlayerInfo[playerid][pKills] = 0;
PlayerInfo[playerid][pDeaths] = 0;
PlayerInfo[playerid][pSkin] = 0;
PlayerInfo[playerid][pScore] = 0;
PlayerInfo[playerid][pCash] = 5000;
PlayerInfo[playerid][pColor] = -1;
GivePlayerMoney(playerid, 5000);
SetPlayerColor(playerid, -1);
SetPlayerScore(playerid, 0);
GameTextForPlayer(playerid, "You succesfully registered your account !Welcome to the server :-).", 10000, 4);
}
}
case DIALOG_LOGIN:
{
if ( !response ) {
Kick ( playerid );
}
else
{
if(LoginPlayer(playerid, inputtext))
{
SetPlayerColor(playerid, PlayerInfo[playerid][pColor]);
SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
}
return 1;
}
}
}
return 1;
}
When i Go To Users in Scriptfiles give number to Them And Re Run Server That's Not Change In Server
Please Give Me True Codes For Submit This {New_Exp & Old_Exp & My_Level & My_ExpFNL} Thank's A lot