SA-MP Forums Archive
Hello, help ;) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Hello, help ;) (/showthread.php?tid=583342)



Hello, help ;) - Mariciuc223 - 27.07.2015

I added some classes to my Gamemode and if i relog i need to select again my class ... I want to know how i can spawn player without selecting again class if he selected 1 time (Spawn he with class skin) Can anyone tell me how ?


AW: Hello, help ;) - Mencent - 27.07.2015

Hello!
You have to save this action that you done this one times.
Do you work with MySQL or y_ini (or other filesystems)?


Re: Hello, help ;) - Moudix - 27.07.2015

Use y_ini for saving , then :
https://sampwiki.blast.hk/wiki/SetSpawnInfo


Re: Hello, help ;) - Mariciuc223 - 27.07.2015

I work with y_ini ( I don't know mysql ) [Thx for fast answer]

EDIT: Can give one of you an exemple of how to save that ?


AW: Hello, help ;) - Mencent - 27.07.2015

When you give me an example how you save your other stuff, then I can try to help you.


Re: Hello, help ;) - Mariciuc223 - 27.07.2015

Код:
public OnPlayerDisconnect(playerid, reason)
{
	new INI:File = INI_Open(UserPath(playerid));
	INI_SetTag(File,"data");

	INI_WriteInt(File, "Password", pInfo[playerid][pPass]);
	INI_WriteInt(File, "Level", pInfo[playerid][pLevel]);
	INI_WriteInt(File, "Gender", pInfo[playerid][pSex]);
	INI_WriteInt(File, "Age", pInfo[playerid][pAge]);
	INI_WriteInt(File, "FirstSpawn", pInfo[playerid][pFirstSpawn]);
	INI_WriteInt(File, "SpawnHealth", pInfo[playerid][pSpawnHealth]);
	INI_WriteInt(File, "Money", pInfo[playerid][pCash]);
	INI_WriteInt(File, "BankMoney", pInfo[playerid][pBankCash]);
	INI_WriteInt(File, "PhoneNr", pInfo[playerid][pPhoneNr]);
	INI_WriteInt(File, "RespectPoints", pInfo[playerid][pRespectPoints]);
	INI_WriteInt(File, "Warnings", pInfo[playerid][pWarnings]);
	INI_WriteInt(File, "FactionWarnings", pInfo[playerid][pFactionW]);
	INI_WriteInt(File, "Lotto", pInfo[playerid][pLotto]);
	INI_WriteInt(File, "PowerUser", pInfo[playerid][pPowerUser]);
	INI_WriteInt(File, "UpgradePoints", pInfo[playerid][pUpgradePoints]);
	INI_WriteInt(File, "WantedLevel", pInfo[playerid][pWanted]);
	INI_WriteInt(File, "Jail", pInfo[playerid][pJail]);
	INI_WriteInt(File, "JailTime", pInfo[playerid][pJailTime]);
	INI_WriteInt(File, "RobPoints", pInfo[playerid][pRobPoints]);
	INI_WriteInt(File, "Kills", pInfo[playerid][pKills]);
	INI_WriteInt(File, "Deaths", pInfo[playerid][pDeaths]);
	INI_WriteInt(File, "Job", pInfo[playerid][pJob]);
	INI_WriteInt(File, "Drugs", pInfo[playerid][pDrugs]);
	INI_WriteInt(File, "Materials", pInfo[playerid][pMaterials]);
	INI_WriteInt(File, "FactionBlackList", pInfo[playerid][pFBlackList]);
	INI_WriteInt(File, "AdminLevel", pInfo[playerid][pAdmin]);
	INI_WriteInt(File, "HelperLevel", pInfo[playerid][pHelper]);
	INI_WriteInt(File, "Leader", pInfo[playerid][pLeader]);
	INI_WriteInt(File, "Faction", pInfo[playerid][pFaction]);
	INI_WriteInt(File, "Rank", pInfo[playerid][pRank]);
	INI_WriteInt(File, "Skin", pInfo[playerid][pSkin]);
	INI_WriteInt(File, "Tutorial", pInfo[playerid][pTutorial]);

	INI_SetTag(File, "time");

 	INI_WriteInt(File, "PowerUser_Year", pInfo[playerid][pPUYear]);
 	INI_WriteInt(File, "PowerUser_Month", pInfo[playerid][pPUMonth]);
 	INI_WriteInt(File, "PowerUser_Day", pInfo[playerid][pPUDay]);
 	INI_WriteInt(File, "PowerUser_Hour", pInfo[playerid][pPUHour]);
 	INI_WriteInt(File, "PowerUser_Minute", pInfo[playerid][pPUMinute]);
 	INI_WriteInt(File, "PowerUser_Second", pInfo[playerid][pPUSecond]);

	INI_Close(File);

	KillTimer(SetTimerEx("Spawn", 3, false, "i", playerid));
	KillTimer(SetTimerEx("Tutorial", 10000, false, "i", playerid));
	KillTimer(SetTimerEx("Freeze", 2000, false, "i", playerid));
	KillTimer(SetTimerEx("UnFreeze", 2000, false, "i", playerid));
	KillTimer(SetTimerEx("JailTime", 1000, true, "i", playerid));
	KillTimer(SetTimerEx("Check", 1000, true, "i", playerid));

	TextDrawHideForPlayer(playerid, Time);
	TextDrawHideForPlayer(playerid, Date);

	return 1;
}
I'm going to sleep , good night (hope you will done something - it's 00 in my country)

Bonus: How i save [EDIT:load i was drank last nigt :P]

Код:
public LoadUser_data(playerid,name[],value[])
{
	INI_Int("Password", pInfo[playerid][pPass]);
	INI_Int("Level", pInfo[playerid][pLevel]);
	INI_Int("Age", pInfo[playerid][pAge]);
	INI_Int("FirstSpawn", pInfo[playerid][pFirstSpawn]);
	INI_Int("Gender", pInfo[playerid][pSex]);
	INI_Int("SpawnHealth", pInfo[playerid][pSpawnHealth]);
	INI_Int("Money", pInfo[playerid][pCash]);
	INI_Int("BankMoney", pInfo[playerid][pBankCash]);
	INI_Int("PhoneNr", pInfo[playerid][pPhoneNr]);
	INI_Int("RespectPoints", pInfo[playerid][pRespectPoints]);
	INI_Int("Warnings", pInfo[playerid][pWarnings]);
	INI_Int("FactionWarnings", pInfo[playerid][pFactionW]);
	INI_Int("Lotto", pInfo[playerid][pLotto]);
	INI_Int("PowerUser", pInfo[playerid][pPowerUser]);
	INI_Int("UpgradePoints", pInfo[playerid][pUpgradePoints]);
	INI_Int("WantedLevel", pInfo[playerid][pWanted]);
	INI_Int("Jail", pInfo[playerid][pJail]);
	INI_Int("RobPoints", pInfo[playerid][pRobPoints]);
	INI_Int("Kills", pInfo[playerid][pKills]);
	INI_Int("Deaths", pInfo[playerid][pDeaths]);
	INI_Int("Job", pInfo[playerid][pJob]);
	INI_Int("Drugs", pInfo[playerid][pDrugs]);
	INI_Int("Materials", pInfo[playerid][pMaterials]);
	INI_Int("FactionBlackList", pInfo[playerid][pFBlackList]);
	INI_Int("AdminLevel", pInfo[playerid][pAdmin]);
	INI_Int("HelperLevel", pInfo[playerid][pHelper]);
	INI_Int("Leader", pInfo[playerid][pLeader]);
	INI_Int("Faction", pInfo[playerid][pFaction]);
	INI_Int("Rank", pInfo[playerid][pRank]);
	INI_Int("pSkin", pInfo[playerid][pSkin]);
	INI_Int("Tutorial", pInfo[playerid][pTutorial]);

	INI_Int("PowerUser_Year", pInfo[playerid][pPUYear]);
 	INI_Int("PowerUser_Month", pInfo[playerid][pPUMonth]);
 	INI_Int("PowerUser_Day", pInfo[playerid][pPUDay]);
 	INI_Int("PowerUser_Hour", pInfo[playerid][pPUHour]);
 	INI_Int("PowerUser_Minute", pInfo[playerid][pPUMinute]);
 	INI_Int("PowerUser_Second", pInfo[playerid][pPUSecond]);

	return 1;
}



AW: Hello, help ;) - Mencent - 27.07.2015

PHP код:
//in your pInfo:
pClassSelection
//if you are through the class selection:
pInfo[playerid][pClassSelection] = 1;
public 
OnPlayerDisconnect(playeridreason)
{
    new 
INI:File INI_Open(UserPath(playerid));
    
INI_SetTag(File,"data");
    
INI_WriteInt(File"Password"pInfo[playerid][pPass]);
    
INI_WriteInt(File"Level"pInfo[playerid][pLevel]);
    
INI_WriteInt(File"Gender"pInfo[playerid][pSex]);
    
INI_WriteInt(File"Age"pInfo[playerid][pAge]);
    
INI_WriteInt(File"FirstSpawn"pInfo[playerid][pFirstSpawn]);
    
INI_WriteInt(File"SpawnHealth"pInfo[playerid][pSpawnHealth]);
    
INI_WriteInt(File"Money"pInfo[playerid][pCash]);
    
INI_WriteInt(File"BankMoney"pInfo[playerid][pBankCash]);
    
INI_WriteInt(File"PhoneNr"pInfo[playerid][pPhoneNr]);
    
INI_WriteInt(File"RespectPoints"pInfo[playerid][pRespectPoints]);
    
INI_WriteInt(File"Warnings"pInfo[playerid][pWarnings]);
    
INI_WriteInt(File"FactionWarnings"pInfo[playerid][pFactionW]);
    
INI_WriteInt(File"Lotto"pInfo[playerid][pLotto]);
    
INI_WriteInt(File"PowerUser"pInfo[playerid][pPowerUser]);
    
INI_WriteInt(File"UpgradePoints"pInfo[playerid][pUpgradePoints]);
    
INI_WriteInt(File"WantedLevel"pInfo[playerid][pWanted]);
    
INI_WriteInt(File"Jail"pInfo[playerid][pJail]);
    
INI_WriteInt(File"JailTime"pInfo[playerid][pJailTime]);
    
INI_WriteInt(File"RobPoints"pInfo[playerid][pRobPoints]);
    
INI_WriteInt(File"Kills"pInfo[playerid][pKills]);
    
INI_WriteInt(File"Deaths"pInfo[playerid][pDeaths]);
    
INI_WriteInt(File"Job"pInfo[playerid][pJob]);
    
INI_WriteInt(File"Drugs"pInfo[playerid][pDrugs]);
    
INI_WriteInt(File"Materials"pInfo[playerid][pMaterials]);
    
INI_WriteInt(File"FactionBlackList"pInfo[playerid][pFBlackList]);
    
INI_WriteInt(File"AdminLevel"pInfo[playerid][pAdmin]);
    
INI_WriteInt(File"HelperLevel"pInfo[playerid][pHelper]);
    
INI_WriteInt(File"Leader"pInfo[playerid][pLeader]);
    
INI_WriteInt(File"Faction"pInfo[playerid][pFaction]);
    
INI_WriteInt(File"Rank"pInfo[playerid][pRank]);
    
INI_WriteInt(File"Skin"pInfo[playerid][pSkin]);
    
INI_WriteInt(File"Tutorial"pInfo[playerid][pTutorial]);
    
INI_WriteInt(File"Class"pInfo[playerid][pClassSelection]);
    
INI_SetTag(File"time");
     
INI_WriteInt(File"PowerUser_Year"pInfo[playerid][pPUYear]);
     
INI_WriteInt(File"PowerUser_Month"pInfo[playerid][pPUMonth]);
     
INI_WriteInt(File"PowerUser_Day"pInfo[playerid][pPUDay]);
     
INI_WriteInt(File"PowerUser_Hour"pInfo[playerid][pPUHour]);
     
INI_WriteInt(File"PowerUser_Minute"pInfo[playerid][pPUMinute]);
     
INI_WriteInt(File"PowerUser_Second"pInfo[playerid][pPUSecond]);
    
INI_Close(File);
    
KillTimer(SetTimerEx("Spawn"3false"i"playerid));
    
KillTimer(SetTimerEx("Tutorial"10000false"i"playerid));
    
KillTimer(SetTimerEx("Freeze"2000false"i"playerid));
    
KillTimer(SetTimerEx("UnFreeze"2000false"i"playerid));
    
KillTimer(SetTimerEx("JailTime"1000true"i"playerid));
    
KillTimer(SetTimerEx("Check"1000true"i"playerid));
    
TextDrawHideForPlayer(playeridTime);
    
TextDrawHideForPlayer(playeridDate);
    return 
1;
}
//where you set in the class selection
INI_Int("Class",pInfo[playerid][pClassSelection]);
if(
pInfo[playerid][pClassSelection] == 1)
{
    
//Set out of the class selection
}
else
{
    
//the player never was in the class selection

I hope it will work or you get an idea how you can solve this.