SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 02/06/2012, 04:27 PM   #1
Mikibey
Little Clucker
 
Join Date: May 2012
Posts: 37
Reputation: 0
Question [y_yni]Player's positions/skins is not saved.

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:
Code:
// 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(playername));
    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 is offline   Reply With Quote
Old 02/06/2012, 04:45 PM   #2
Mikibey
Little Clucker
 
Join Date: May 2012
Posts: 37
Reputation: 0
Default Re: [y_yni]Player's positions/skins is not saved.

how can i do this?
Mikibey is offline   Reply With Quote
Old 02/06/2012, 04:52 PM   #3
Mikibey
Little Clucker
 
Join Date: May 2012
Posts: 37
Reputation: 0
Default Re: [y_yni]Player's positions/skins is not saved.

i dont have any money.. sry...
Mikibey is offline   Reply With Quote
Old 02/06/2012, 05:20 PM   #4
zombieking
Huge Clucker
 
Join Date: Jun 2011
Posts: 435
Reputation: 33
Default Re: [y_yni]Player's positions/skins is not saved.

in the pInfo enum add pSkin like this:
pawn Code:
enum pInfo
{
    pPass,
    pCash,
    pAdmin,
    pKills,
    pSkin,
    pDeaths
}

Now at the register dialog:
pawn Code:
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:
pawn Code:
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:
pawn Code:
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...:
pawn Code:
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
zombieking is offline   Reply With Quote
Old 02/06/2012, 08:01 PM   #5
Mikibey
Little Clucker
 
Join Date: May 2012
Posts: 37
Reputation: 0
Default Re: [y_yni]Player's positions/skins is not saved.

Quote:
Originally Posted by zombieking View Post
in the pInfo enum add pSkin like this:
pawn Code:
enum pInfo
{
    pPass,
    pCash,
    pAdmin,
    pKills,
    pSkin,
    pDeaths
}

Now at the register dialog:
pawn Code:
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:
pawn Code:
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:
pawn Code:
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...:
pawn Code:
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
Mikibey is offline   Reply With Quote
Old 02/06/2012, 08:14 PM   #6
Edward156
Big Clucker
 
Edward156's Avatar
 
Join Date: May 2012
Location: Doing everything for the glory of God.
Posts: 98
Reputation: 9
Default Re: [y_yni]Player's positions/skins is not saved.

Quote:
Originally Posted by Mikibey View Post
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.
__________________
chєck σut mч rσlєplαч sєrvєr:
216.224.179.15:7777
Edward156 is offline   Reply With Quote
Old 03/06/2012, 07:48 AM   #7
Mikibey
Little Clucker
 
Join Date: May 2012
Posts: 37
Reputation: 0
Default Re: [y_yni]Player's positions/skins is not saved.

oh so "INI_WriteInt(File,"Skin",0);" is INI_WriteInt(File,"Skin",60);?
Mikibey is offline   Reply With Quote
Old 03/06/2012, 07:49 AM   #8
zombieking
Huge Clucker
 
Join Date: Jun 2011
Posts: 435
Reputation: 33
Default Re: [y_yni]Player's positions/skins is not saved.

Yeah... You can change that
zombieking is offline   Reply With Quote
Old 03/06/2012, 04:44 PM   #9
Edward156
Big Clucker
 
Edward156's Avatar
 
Join Date: May 2012
Location: Doing everything for the glory of God.
Posts: 98
Reputation: 9
Default Re: [y_yni]Player's positions/skins is not saved.

Quote:
Originally Posted by Mikibey View Post
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.
__________________
chєck σut mч rσlєplαч sєrvєr:
216.224.179.15:7777
Edward156 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Car in position save Igdirli 76 Scripting Help 4 22/10/2011 03:12 PM
I need help! pls! /s and /r or /l script or fs save position and load position ProdrifterX Scripting Help 2 14/10/2011 05:02 PM
Save position ? [LNL]Remulis Help Archive 3 09/05/2009 08:23 PM


All times are GMT. The time now is 05:40 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.