PDA

View Full Version : [y_yni]Player's positions/skins is not saved.


Mikibey
02/06/2012, 03:27 PM
So as the title say's,when i first login the server spawns me in the right place,and with the skin "60",the id that i've chosen,but if i relog,the server spawns me in air in a weird place and also it spawns me with skin 0 ... please can you help me?
I am desperate to make this sistem to work,i rly need to learn how lol:) (Working on this thing to work well for 3 days already lol

here is my full code until now:

// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

//Includes
#include <a_samp>
#include <dini>
#include <a_samp>
#include <dini>
#include <YSI\y_ini>
#include <dudb>
#include <file>

#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
#define DIALOG_SUCCESS_1 3
#define DIALOG_SUCCESS_2 4

#define PATH "/Users/%s.ini"

#define COL_WHITE "{FFFFFF}"
#define COL_RED "{F81414}"
#define COL_GREEN "{00FF22}"
#define COL_LIGHTBLUE "{00CED1}"
//Enums
enum pInfo
{
pPass,
pCash,
pAdmin,
pKills,
pDeaths
}

new PlayerInfo[MAX_PLAYERS][pInfo];
new gPlayerLogged[MAX_PLAYERS];

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("Admin",PlayerInfo[playerid][pAdmin]);
INI_Int("Kills",PlayerInfo[playerid][pKills]);
INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
return 1;
}

stock UserPath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playernam e));
format(string,sizeof(string),PATH,playername);
return string;
}

main()
{
print("\n----------------------------------");
print("GG-Reallife 0.1");
print("----------------------------------\n");
}

public OnGameModeInit()
{
//Clase Pentru Select ForceClassSelection(playerid); dupa login
SetGameModeText("GG-Reallife 0.1");
//Vehicule Los Santos
AddStaticVehicle(402,1363.1136,-1300.6017,13.2846,181.8885,13,13);
AddStaticVehicle(405,1329.5442,-1369.1112,13.5429,268.5680,24,1);
AddStaticVehicle(412,1085.3099,-1366.2987,13.5083,359.8742,64,1);
AddStaticVehicle(424,951.2397,-1364.3125,13.2168,92.9506,88,64);
AddStaticVehicle(426,965.5166,-1369.2640,13.2127,270.9866,88,64);
AddStaticVehicle(445,676.1548,-1428.2697,14.7267,0.0399,88,64);
AddStaticVehicle(458,1460.3394,-1506.6311,13.4155,89.3990,88,64);
AddStaticVehicle(466,1507.6152,-1750.6693,13.2740,358.9849,123,1);
AddStaticVehicle(467,1535.9390,-1672.0173,13.1099,359.4517,123,1);
AddStaticVehicle(479,1282.4524,-1522.9989,13.2908,270.2958,123,1);
AddStaticVehicle(489,1920.7021,-1790.3239,13.1119,269.2996,123,1);
AddStaticVehicle(496,1946.6371,-2123.7000,13.2749,89.5041,123,1);
AddStaticVehicle(499,1776.9808,-1887.3065,13.1141,88.2713,112,1);
AddStaticVehicle(517,1775.9952,-1932.7899,13.1131,175.6704,112,1);
AddStaticVehicle(529,1805.3340,-1932.5547,13.1135,0.7090,112,1);
AddStaticVehicle(604,1674.8048,-1125.0746,23.6333,267.5852,112,1);
AddStaticVehicle(605,1685.7198,-1044.8259,23.6333,358.9815,112,1);
AddStaticVehicle(425,1761.6339,-1046.5703,23.6880,359.6237,112,1);
AddStaticVehicle(412,1651.7705,-1018.0209,23.6255,9.5531,112,1);
AddStaticVehicle(481,1592.7891,-1057.7676,23.6333,129.2202,112,1);
AddStaticVehicle(521,1328.0367,-1061.3395,28.6363,1.8183,112,1);
AddStaticVehicle(600,1027.6488,-1052.6136,31.3748,177.2368,112,1);
AddStaticVehicle(531,1066.8021,-876.1398,42.9531,85.8525,112,1);
AddStaticVehicle(579,1065.7228,-902.9531,42.8549,264.3694,112,1);
AddStaticVehicle(554,1706.7697,-1879.4489,13.4003,357.7852,13,13);
AddStaticVehicle(549,1618.3584,-1559.6875,14.0050,87.9495,13,13);
AddStaticVehicle(566,1549.5625,-2211.9944,13.3864,179.6881,13,13);
AddStaticVehicle(579,297.8336,-1366.4697,13.9333,22.6049,13,13);
AddStaticVehicle(554,442.9940,-1738.1919,9.2225,179.3603,13,13);
AddStaticVehicle(479,823.4073,-2028.5421,12.6989,268.6736,13,13);
AddStaticVehicle(412,824.0782,-1915.5522,12.6989,88.9128,13,13);
AddStaticVehicle(418,1062.5624,-1737.5902,13.3109,90.1607,13,13);
//Vehicule Los Santos Sfarsit

return 1;
}

public OnGameModeExit()
{
return 1;
}
// aici ii da pe playeri
public OnPlayerRequestClass(playerid, classid)
{
return 1;
}

public OnPlayerConnect(playerid)
{
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""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(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
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[])
{
return 1;
}
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(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_Close(File);

SetSpawnInfo(playerid, 0, 60, 1480.8102, -1758.8420, 17.5313, 342.1488, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Welcome to G-Zone,we hope you will have a great time with us.!","Ok","");
}
}

case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
{
INI_ParseFile(UserPath(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;
}

Mikibey
02/06/2012, 03:45 PM
how can i do this?

Mikibey
02/06/2012, 03:52 PM
i dont have any money..:( sry...

zombieking
02/06/2012, 04:20 PM
in the pInfo enum add pSkin like this:
enum pInfo
{
pPass,
pCash,
pAdmin,
pKills,
pSkin,
pDeaths
}

Now at the register dialog:
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(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_WriteInt(File,"Skin",0); // We'll set it to 0 for now
INI_Close(File);

Now go to OnPlayerSpawn and:
public OnPlayerSpawn(playerid)
{
new INI:File = INI_Open(UserPath(playerid));
INI_WriteInt(File,"Skin",GetPlayerSkin(playerid));
INI_Close(File);
SetPlayerSkin(playerid,PlayerInfo[playerid][pSkin]);
return 1;
}

Now go to public LoadUser_data and:
INI_Int("Password",PlayerInfo[playerid][pPass]);
INI_Int("Cash",PlayerInfo[playerid][pCash]);
INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
INI_Int("Kills",PlayerInfo[playerid][pKills]);
INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
INI_Int("Skin",PlayerInfo[playerid][pSkin);


So you simply add INI_Int("Skin",PlayerInfo[playerid][pSkin);

Add it to OnPlayerDisconnect also...:
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_WriteInt(File,"Skin",PlayerInfo[playerid][pSkin]);
INI_Close(File);

I haven't tested this.. So try it

Mikibey
02/06/2012, 07:01 PM
in the pInfo enum add pSkin like this:
enum pInfo
{
pPass,
pCash,
pAdmin,
pKills,
pSkin,
pDeaths
}

Now at the register dialog:
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(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_WriteInt(File,"Skin",0); // We'll set it to 0 for now
INI_Close(File);

Now go to OnPlayerSpawn and:
public OnPlayerSpawn(playerid)
{
new INI:File = INI_Open(UserPath(playerid));
INI_WriteInt(File,"Skin",GetPlayerSkin(playerid));
INI_Close(File);
SetPlayerSkin(playerid,PlayerInfo[playerid][pSkin]);
return 1;
}

Now go to public LoadUser_data and:
INI_Int("Password",PlayerInfo[playerid][pPass]);
INI_Int("Cash",PlayerInfo[playerid][pCash]);
INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
INI_Int("Kills",PlayerInfo[playerid][pKills]);
INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
INI_Int("Skin",PlayerInfo[playerid][pSkin);


So you simply add INI_Int("Skin",PlayerInfo[playerid][pSkin);

Add it to OnPlayerDisconnect also...:
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_WriteInt(File,"Skin",PlayerInfo[playerid][pSkin]);
INI_Close(File);

I haven't tested this.. So try it

thanks,but i cannot make it to start with the skin 60,now when i set the player to start with the skin 60 its starting with skin 0:(

Edward156
02/06/2012, 07:14 PM
thanks,but i cannot make it to start with the skin 60,now when i set the player to start with the skin 60 its starting with skin 0:(

You have to change your saved skin ID in your user profile/settings since it has already but set.

Mikibey
03/06/2012, 06:48 AM
oh so "INI_WriteInt(File,"Skin",0);" is INI_WriteInt(File,"Skin",60);?

zombieking
03/06/2012, 06:49 AM
Yeah... You can change that

Edward156
03/06/2012, 03:44 PM
oh so "INI_WriteInt(File,"Skin",0);" is INI_WriteInt(File,"Skin",60);?

Go open your user profile/account which should be saved in one file. Then where it says Skin:, change 0 to whatever.