17.10.2011, 23:49
(
Последний раз редактировалось Buzzbomb; 18.10.2011 в 02:13.
)
Um i fixed the saving But how do i load Not familiar with Y_ini Someone please correct my issue heres the Full Script got it from Siin but he didnt reply to his Posts he went offline..
If you dont Under Stand What Im Asking .... How Do i load Player Positions.. Clearly... this aint working
INI_Int("LocX",PlayerInfo[playerid][pLocX]);
So what Other Way Is there.. Offer People to Switch to Y_INI and cant get no Support...
If you dont Under Stand What Im Asking .... How Do i load Player Positions.. Clearly... this aint working
INI_Int("LocX",PlayerInfo[playerid][pLocX]);
So what Other Way Is there.. Offer People to Switch to Y_INI and cant get no Support...
pawn Код:
//Credits to ******, Dracoblue and Kush.
#include <a_samp>
#include <YSI\y_ini>
#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
#define DIALOG_SUCCESS_1 3
#define DIALOG_SUCCESS_2 4
#define ARS_ACCOUNTS "ARS/Accounts/%s.ini"
#define COL_WHITE "{FFFFFF}"
#define COL_RED "{F81414}"
#define COL_GREEN "{00FF22}"
#define COL_LIGHTBLUE "{00CED1}"
enum pInfo
{
pPass,
pCash,
pBank,
pAdmin,
pKills,
pDeaths,
pFirstname,
pLastname,
pAge,
pGender,
pCharacter,
pScore,
pFrank,
pPrank,
pFireTeam,
pPoliceTeam,
pMedicTeam,
pHealth,
pArmour,
pLocX,
pLocY,
pLocZ,
pLocA,
pLocI,
pLocW,
pWeap1,
pWeap2,
pWeap3,
pWeap4,
pWeap5,
pWeap6,
pWeap7,
pWeap8,
pWeap9,
pWeap10,
pWeap11,
pWeap12,
pAmmo1,
pAmmo2,
pAmmo3,
pAmmo4,
pAmmo5,
pAmmo6,
pAmmo7,
pAmmo8,
pAmmo9,
pAmmo10,
pAmmo11,
pAmmo12
}
new PlayerInfo[MAX_PLAYERS][pInfo];
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Password",PlayerInfo[playerid][pPass]);
INI_Int("Cash",PlayerInfo[playerid][pCash]);
INI_Int("Bank",PlayerInfo[playerid][pBank]);
INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
INI_Int("Kills",PlayerInfo[playerid][pKills]);
INI_Int("Firstname",PlayerInfo[playerid][pFirstname]);
INI_Int("Lastname",PlayerInfo[playerid][pLastname]);
INI_Int("Age",PlayerInfo[playerid][pAge]);
INI_Int("Gender",PlayerInfo[playerid][pGender]);
INI_Int("Character",PlayerInfo[playerid][pCharacter]);
INI_Int("Score",PlayerInfo[playerid][pScore]);
INI_Int("Frank",PlayerInfo[playerid][pFrank]);
INI_Int("Prank",PlayerInfo[playerid][pPrank]);
INI_Int("FireTeam",PlayerInfo[playerid][pFireTeam]);
INI_Int("MedicTeam",PlayerInfo[playerid][pMedicTeam]);
INI_Int("PoliceTeam",PlayerInfo[playerid][pPoliceTeam]);
INI_Int("Health",PlayerInfo[playerid][pHealth]);
INI_Int("Armour",PlayerInfo[playerid][pArmour]);
INI_Int("LocX",PlayerInfo[playerid][pLocX]);
INI_Int("LocY",PlayerInfo[playerid][pLocY]);
INI_Int("LocZ",PlayerInfo[playerid][pLocZ]);
INI_Int("LocA",PlayerInfo[playerid][pLocA]);
INI_Int("LocI",PlayerInfo[playerid][pLocI]);
INI_Int("LocW",PlayerInfo[playerid][pLocW]);
INI_Int("Weap1",PlayerInfo[playerid][pWeap1]);
INI_Int("Weap2",PlayerInfo[playerid][pWeap2]);
INI_Int("Weap3",PlayerInfo[playerid][pWeap3]);
INI_Int("Weap4",PlayerInfo[playerid][pWeap4]);
INI_Int("Weap5",PlayerInfo[playerid][pWeap5]);
INI_Int("Weap6",PlayerInfo[playerid][pWeap6]);
INI_Int("Weap7",PlayerInfo[playerid][pWeap7]);
INI_Int("Weap8",PlayerInfo[playerid][pWeap8]);
INI_Int("Weap10",PlayerInfo[playerid][pWeap10]);
INI_Int("Weap11",PlayerInfo[playerid][pWeap11]);
INI_Int("Weap12",PlayerInfo[playerid][pWeap12]);
INI_Int("Ammo1",PlayerInfo[playerid][pAmmo1]);
INI_Int("Ammo2",PlayerInfo[playerid][pAmmo2]);
INI_Int("Ammo3",PlayerInfo[playerid][pAmmo3]);
INI_Int("Ammo4",PlayerInfo[playerid][pAmmo4]);
INI_Int("Ammo5",PlayerInfo[playerid][pAmmo5]);
INI_Int("Ammo6",PlayerInfo[playerid][pAmmo6]);
INI_Int("Ammo7",PlayerInfo[playerid][pAmmo7]);
INI_Int("Ammo8",PlayerInfo[playerid][pAmmo8]);
INI_Int("Ammo9",PlayerInfo[playerid][pAmmo9]);
INI_Int("Ammo10",PlayerInfo[playerid][pAmmo10]);
INI_Int("Ammo11",PlayerInfo[playerid][pAmmo11]);
INI_Int("Ammo12",PlayerInfo[playerid][pAmmo12]);
return 1;
}
stock ArsPath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string,sizeof(string),ARS_ACCOUNTS,playername);
return string;
}
/*Credits to Dracoblue*/
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;
}
main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}
public OnGameModeInit()
{
SetGameModeText("Blank Script");
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
return 1;
}
public OnPlayerConnect(playerid)
{
if(fexist(ArsPath(playerid)))
{
INI_ParseFile(ArsPath(playerid), "LoadUser_%s", .bExtra = true, .extra = 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 INI:File = INI_Open(ArsPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Bank",PlayerInfo[playerid][pBank]);
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_WriteInt(File,"Firstname",PlayerInfo[playerid][pFirstname]);
INI_WriteInt(File,"Lastname",PlayerInfo[playerid][pLastname]);
INI_WriteInt(File,"Age",PlayerInfo[playerid][pAge]);
INI_WriteInt(File,"Gender",PlayerInfo[playerid][pGender]);
INI_WriteInt(File,"Character",GetPlayerSkin(playerid));
INI_WriteInt(File,"Score",PlayerInfo[playerid][pScore]);
INI_WriteInt(File,"Frank",PlayerInfo[playerid][pFrank]);
INI_WriteInt(File,"Prank",PlayerInfo[playerid][pPrank]);
INI_WriteInt(File,"FireTeam",PlayerInfo[playerid][pFireTeam]);
INI_WriteInt(File,"MedicTeam",PlayerInfo[playerid][pMedicTeam]);
INI_WriteInt(File,"PoliceTeam",PlayerInfo[playerid][pPoliceTeam]);
new Float:ARMOUR, Float:HEALTH;
GetPlayerArmour(playerid,ARMOUR);
GetPlayerHealth(playerid,HEALTH);
new Float:X, Float:Y, Float:Z, Float:A, Float:I, Float:W;
GetPlayerPos(playerid, X,Y,Z);
GetPlayerFacingAngle(playerid, A);
I = GetPlayerInterior(playerid);
W = GetPlayerVirtualWorld(playerid);
INI_WriteFloat(File,"Health",HEALTH);
INI_WriteFloat(File,"Armour",ARMOUR);
INI_WriteFloat(File,"LocX",X);
INI_WriteFloat(File,"LocY",Y);
INI_WriteFloat(File,"LocZ",Z);
INI_WriteFloat(File,"LocA",A);
INI_WriteFloat(File,"LocI",I);
INI_WriteFloat(File,"LocW",W);
INI_WriteInt(File,"Weap1",PlayerInfo[playerid][pWeap1]);
INI_WriteInt(File,"Weap2",PlayerInfo[playerid][pWeap2]);
INI_WriteInt(File,"Weap3",PlayerInfo[playerid][pWeap3]);
INI_WriteInt(File,"Weap4",PlayerInfo[playerid][pWeap4]);
INI_WriteInt(File,"Weap5",PlayerInfo[playerid][pWeap5]);
INI_WriteInt(File,"Weap6",PlayerInfo[playerid][pWeap6]);
INI_WriteInt(File,"Weap7",PlayerInfo[playerid][pWeap7]);
INI_WriteInt(File,"Weap8",PlayerInfo[playerid][pWeap8]);
INI_WriteInt(File,"Weap10",PlayerInfo[playerid][pWeap10]);
INI_WriteInt(File,"Weap11",PlayerInfo[playerid][pWeap11]);
INI_WriteInt(File,"Weap12",PlayerInfo[playerid][pWeap12]);
INI_WriteInt(File,"Ammo1",PlayerInfo[playerid][pAmmo1]);
INI_WriteInt(File,"Ammo2",PlayerInfo[playerid][pAmmo2]);
INI_WriteInt(File,"Ammo3",PlayerInfo[playerid][pAmmo3]);
INI_WriteInt(File,"Ammo4",PlayerInfo[playerid][pAmmo4]);
INI_WriteInt(File,"Ammo5",PlayerInfo[playerid][pAmmo5]);
INI_WriteInt(File,"Ammo6",PlayerInfo[playerid][pAmmo6]);
INI_WriteInt(File,"Ammo7",PlayerInfo[playerid][pAmmo7]);
INI_WriteInt(File,"Ammo8",PlayerInfo[playerid][pAmmo8]);
INI_WriteInt(File,"Ammo9",PlayerInfo[playerid][pAmmo9]);
INI_WriteInt(File,"Ammo10",PlayerInfo[playerid][pAmmo10]);
INI_WriteInt(File,"Ammo11",PlayerInfo[playerid][pAmmo11]);
INI_WriteInt(File,"Ammo12",PlayerInfo[playerid][pAmmo12]);
INI_Close(File);
return 1;
}
public OnPlayerSpawn(playerid)
{
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
PlayerInfo[killerid][pKills]++;
PlayerInfo[playerid][pDeaths]++;
return 1;
}
public OnVehicleSpawn(vehicleid)
{
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}
public OnPlayerText(playerid, text[])
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}
public OnRconCommand(cmd[])
{
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
return 1;
}
public OnObjectMoved(objectid)
{
return 1;
}
public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}
public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}
public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
return 1;
}
public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}
public OnPlayerExitedMenu(playerid)
{
return 1;
}
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}
public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}
public OnPlayerUpdate(playerid)
{
return 1;
}
public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}
public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}
public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}
public OnVehicleStreamOut(vehicleid, forplayerid)
{
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 INI:File = INI_Open(ArsPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteInt(File,"Cash",14536);
INI_WriteInt(File,"Bank",0);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_WriteInt(File,"Firstname",0);
INI_WriteInt(File,"Lastname",0);
INI_WriteInt(File,"Age",0);
INI_WriteInt(File,"Gender",0);
INI_WriteInt(File,"Character",0);
INI_WriteInt(File,"Score",0);
INI_WriteInt(File,"Frank",0);
INI_WriteInt(File,"Prank",0);
INI_WriteInt(File,"FireTeam",0);
INI_WriteInt(File,"MedicTeam",0);
INI_WriteInt(File,"PoliceTeam",0);
INI_WriteInt(File,"Health",0);
INI_WriteInt(File,"Armour",0);
INI_WriteInt(File,"LocX",0);
INI_WriteInt(File,"LocY",0);
INI_WriteInt(File,"LocZ",0);
INI_WriteInt(File,"LocA",0);
INI_WriteInt(File,"LocI",0);
INI_WriteInt(File,"LocW",0);
INI_WriteInt(File,"Weap1",0);
INI_WriteInt(File,"Weap2",0);
INI_WriteInt(File,"Weap3",0);
INI_WriteInt(File,"Weap4",0);
INI_WriteInt(File,"Weap5",0);
INI_WriteInt(File,"Weap6",0);
INI_WriteInt(File,"Weap7",0);
INI_WriteInt(File,"Weap8",0);
INI_WriteInt(File,"Weap10",0);
INI_WriteInt(File,"Weap11",0);
INI_WriteInt(File,"Weap12",0);
INI_WriteInt(File,"Ammo1",0);
INI_WriteInt(File,"Ammo2",0);
INI_WriteInt(File,"Ammo3",0);
INI_WriteInt(File,"Ammo4",0);
INI_WriteInt(File,"Ammo5",0);
INI_WriteInt(File,"Ammo6",0);
INI_WriteInt(File,"Ammo7",0);
INI_WriteInt(File,"Ammo8",0);
INI_WriteInt(File,"Ammo9",0);
INI_WriteInt(File,"Ammo10",0);
INI_WriteInt(File,"Ammo11",0);
INI_WriteInt(File,"Ammo12",0);
INI_Close(File);
SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Great! Your Y_INI system works perfectly. Relog to save your stats!","Ok","");
}
}
case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
{
INI_ParseFile(ArsPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
}
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;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}