21.05.2012, 09:53
PHP код:
stock SavePlayer(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
if(!gPlayerLogged[playerid]) return 1;
format(query, sizeof( query ),"UPDATE `accounts` SET `Admin`='%d', `Tutorial`='%d',\
`Age`='%d', `Sex`='%d', `Origin`='%d', `Model`='%d', `SpawnX`='%f', `SpawnY`='%f',\
`SpawnZ`='%f', `Carkey`='%d', `Cash`='%d', `Bank`='%d', `Leader`='%d', `Member`='%d',\
`Rank`='%d', `Warns`='%d', `InvWeapon`='%d', `InvWeapon2`='%d', `InvWeapon3`='%d',\
`InvAmmo`='%d', `InvAmmo2`='%d', `InvAmmo3`='%d' WHERE `Name`='%s' LIMIT 1",
Player[playerid][pAdmin], Player[playerid][pTutorial], Player[playerid][pAge],
Player[playerid][pSex], Player[playerid][pOrigin], Player[playerid][pModel], Player[playerid][pCordX],
Player[playerid][pCordY], Player[playerid][pCordZ], Player[playerid][pCarkey], Player[playerid][pCash],
Player[playerid][pBank], Player[playerid][pLeader], Player[playerid][pMember], Player[playerid][pRank],
Player[playerid][pWarns], Player[playerid][pInvWeapon], Player[playerid][pInvWeapon2], Player[playerid] [pInvWeapon3],
Player[playerid][pInvAmmo], Player[playerid][pInvAmmo2], Player[playerid][pInvAmmo3],name);
mysql_query(query);
return 1;
}
forward OnPlayerLogin(playerid,password[]);
public OnPlayerLogin(playerid,password[])
{
new name[MAX_PLAYER_NAME],result[MAX_RESULT], string[256];
GetPlayerName(playerid, name, sizeof(name));
format(query,sizeof(query), "SELECT * FROM `accounts` WHERE `Name` = '%s' AND `Password` = '%s'", name,password);
mysql_query(query);
mysql_store_result();
if(mysql_fetch_row(result))
{
format(query,sizeof(query),"SELECT * FROM `accounts` WHERE `Name` = '%s'",name);
mysql_query(query);
mysql_store_result();
if(!mysql_fetch_row(result)) return 0;
sscanf(result, "p<|>s[24]s[32]iiiiiifffiiiiiiiiiiiii", // i - ид (int), s[размер] - string, ник и пароль.
name, Player[playerid][pPass],Player[playerid][pAdmin], Player[playerid][pTutorial], Player[playerid][pAge],
Player[playerid][pSex], Player[playerid][pOrigin], Player[playerid][pModel], Player[playerid][pCordX],
Player[playerid][pCordY], Player[playerid][pCordZ], Player[playerid][pCarkey], Player[playerid][pCash],
Player[playerid][pBank], Player[playerid][pLeader], Player[playerid][pMember], Player[playerid][pRank],
Player[playerid][pWarns], Player[playerid][pInvWeapon], Player[playerid][pInvWeapon2], Player[playerid][pInvWeapon3],
Player[playerid][pInvAmmo], Player[playerid][pInvAmmo2], Player[playerid][pInvAmmo3], Player[playerid][pInvAmmo3]);
if(Player[playerid][pAdmin] > 0)
{
format(string,sizeof(string), "{ffffff}Вы вошли как администратор {03c03c}%d {ffffff}уровня.", Player[playerid][pAdmin]);
SendClientMessage(playerid,COLOR_GRAD1,string);
}
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid,Player[playerid][pCash]);
gPlayerLogged[playerid] = true;
SendClientMessage(playerid,0xFF00000,"Сервер Free Life, делает Stepan23");
mysql_query(query);
SpawnPlayer(playerid);// Спавним игрока
}
return 1;
}