PDA

View Full Version : GMX


Kingunit
30/08/2011, 01:28 PM
Hello,

My skin is saving when I /q. But when I throw a server restart, it's setted back to CJ.
What's wrong with my GMX? Nothing I think so.
GMX:

//-----[Server GMX]-----
CMD:gmx(playerid, params[])
{
SaveUserDate(playerid);

SetTimer("Gmx",3000,false);
SendRconCommand("gmx");
return 1;
}


SaveUserDate

forward SaveUserDate(playerid);
public SaveUserDate(playerid)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Skin",GetPlayerSkin(playerid));
INI_Close(File);
return true;
}

Kingunit
30/08/2011, 01:38 PM
It also doens't work for me (who typed the command).


forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Password",PlayerInfo[playerid][Password]);
INI_Int("Cash",PlayerInfo[playerid][Cash]);
INI_Int("Kills",PlayerInfo[playerid][Kills]);
INI_Int("Deaths",PlayerInfo[playerid][Deaths]);
INI_Int("Score",PlayerInfo[playerid][Score]);
INI_Int("Adminlevel",PlayerInfo[playerid][Adminlevel]);
INI_Int("Skin",PlayerInfo[playerid][Skin]);
return 1;
}

Here I load them. But the weird part is, it's removing after the GMX.
Full SaveUserDate:

forward SaveUserDate(playerid);
public SaveUserDate(playerid)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
PlayerInfo[playerid][Skin] = GetPlayerSkin(playerid);
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Kills",PlayerInfo[playerid][Kills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][Deaths]);
INI_WriteInt(File,"Score",GetPlayerScore(playerid));
INI_WriteInt(File,"Adminlevel",PlayerInfo[playerid][Adminlevel]);
INI_WriteInt(File,"Skin", GetPlayerSkin(playerid));
INI_Close(File);
return true;
}

Kayaque
30/08/2011, 01:40 PM
for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { SaveUserData(i); }}
Thats a fix for what ****** mentioned.

Anyway, what kind of information do you load on playerspawn/requestclass?

Kingunit
30/08/2011, 01:42 PM
OnPlayerSpawn

public OnPlayerSpawn(playerid)
{
SetSpawnInfo( playerid, 0, PlayerInfo[playerid][Skin], 2842.7844,1290.9116,11.3906,93.5261, 0, 0, 0, 0, 0, 0 );
SetPlayerSkin(playerid, PlayerInfo[playerid][Skin]);
return 1;
}


public OnPlayerRequestClass(playerid, classid)
{
SetSpawnInfo( playerid, 0, PlayerInfo[playerid][Skin], 2842.7844,1290.9116,11.3906,93.5261, 0, 0, 0, 0, 0, 0 );
SpawnPlayer(playerid);
return 1;
}


I just don't know wich one I can remove.
@Kayaque
I will implent that. Thank you;)

Venice
30/08/2011, 01:43 PM
CMD:gmx(playerid, params[])
{
for(new i=0; i<MAX_PLAYERS; i++)
SaveUserDate(i);
SetTimer("Gmx",3000,false);
SendRconCommand("gmx");
return 1;
}

try

Kingunit
30/08/2011, 01:49 PM
CMD:gmx(playerid, params[])
{
for(new i=0; i<MAX_PLAYERS; i++)
SaveUserDate(i);
SetTimer("Gmx",3000,false);
SendRconCommand("gmx");
return 1;
}

try

Saving after /q and not saving after GMX. So same story. But it will fix the other problem I think =]

Kingunit
30/08/2011, 02:09 PM
Where do you call INI_ParseFile? You might want to look in to this system:

http://forum.sa-mp.com/showthread.php?t=279986

Can you give me a example of 'parsing' the file? I'm probably new with that. And will that solve my problem?

Kingunit
30/08/2011, 02:19 PM
You have the "LoadUser_data" callback, but no evidence of "INI_ParseFile", which is used to call those callbacks. There are tutorials on y_ini use - see the "My Threads" link in my signature.

Okay, I will check that. But does that solve my problem? Or it's just needed to the for in the futher?

Universal
30/08/2011, 02:31 PM
Hello guys, theres something I would like to ask:


//-----[Server GMX]-----
CMD:gmx(playerid, params[])
{
SaveUserDate(playerid);

SetTimer("Gmx",3000,false); // <---- About this
SendRconCommand("gmx"); // <---- And this
return 1;
}


What does the callback of the timer "Gmx" do? If I understood the code correctly, then you're setting a timer for a gmx command, and then you're instantly calling a SendRconCommand("gmx"); under it..? Am I right?

Kingunit
30/08/2011, 02:32 PM
SendRconCommand("gmx");

That's calling the /rcon gmx. But before that you can save your shit and everything else what you wanna do.
Honestly the Timer is useless, I will remove that later. I just don't know why it's still in my command.

Universal
30/08/2011, 02:37 PM
SendRconCommand("gmx");

That's calling the /rcon gmx. But before that you can save your shit and everything else what you wanna do.
Honestly the Timer is useless, I will remove that later. I just don't know why it's still in my command.
Yes, I know what the function does, I just couldnt figure out that timer and that function under it...

Kingunit
30/08/2011, 03:42 PM
Still didn't worked. I just don't know how to put a 'parser' or whatever.

IceCube!
30/08/2011, 04:08 PM
INI_ParseFile
filename[] - The file to load.
remoteFormat[] - What function to call.
bool:bFileFirst - What order to format the function.
bool:bExtra - Send additional data.
extra - Additional data to send.
bLocal - Call local functions instead of gloabal ones.
bool:bPassTag - What extra data to pass.


Quaote from ******'s tutorial on his system

Should end up looking simalar to this

INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);

and heres his tutorial if you need it

http://forum.sa-mp.com/showthread.php?t=175565

IF you mean somthing else let me know

steki.
30/08/2011, 04:11 PM
It isn't possible to change a player's skin after a GMX. SA:MP bug. You have to die first.

Kingunit
30/08/2011, 04:58 PM
It isn't possible to change a player's skin after a GMX. SA:MP bug. You have to die first.

Are you sure about that? Hmm sounds weird. Going to check if it's true;)

Improvement™
30/08/2011, 06:24 PM
I suggest you to add a print and try using the /gmx command again, and see if the UserData has been saved.
If it will be printed, then I suppose you have done something wrong within the SaveUserData callback.
And if it won't be printed, then you should wait for someone to post a good solution.

forward SaveUserDate(playerid);
public SaveUserDate(playerid)
{
new PlayerName[MAX_PLAYERS];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Skin",GetPlayerSkin(playerid));
INI_Close(File);
printf("[userdata] Player Data of %s has been saved.", PlayerName);
return true;
}

Kingunit
30/08/2011, 07:58 PM
When I use that Printf I'm getting spammed:


[19:57:04] [userdata] Player Data of has been saved.


[19:57:04] [userdata] Player Data of has been saved.


[19:57:04] [userdata] Player Data of has been saved.


[19:57:04] [userdata] Player Data of has been saved.


[19:57:04] [userdata] Player Data of has been saved.


[19:57:04] [userdata] Player Data of has been saved.


[19:57:04] [userdata] Player Data of has been saved.


[19:57:04] [userdata] Player Data of has been saved.


[19:57:04] [userdata] Player Data of has been saved.


[19:57:04] [userdata] Player Data of has been saved.

[19:57:04] [userdata] Player Data of has been saved.


[19:57:04] [userdata] Player Data of has been saved.


[19:57:04] [userdata] Player Data of has been saved.


[19:57:04] [userdata] Player Data of has been saved.


[19:57:04] [userdata] Player Data of has been saved.


[19:57:04] [userdata] Player Data of has been saved.


[19:57:04] [userdata] Player Data of has been saved.


[19:57:04] [userdata] Player Data of has been saved.

Improvement™
30/08/2011, 08:28 PM
if you are using the foreach loop then i suggest you add IsPlayerConnected, so the user datas will only be saved for players that are connected.

//foreach loop
if(IsPlayerConnected(i))
{
//the rest of the codes
}

Improvement™
30/08/2011, 08:55 PM
If you are using foreach you don't need that check - that's one of the major advantages of foreach! It only loops through connected players.

I guess you havent seen the previous page(s), a few others that replied on this topic suggested him using the simple foreach loop. And not the include you released. So therefor I am suggesting him to do that check, within the simple foreach loop.

Kingunit
31/08/2011, 01:53 AM
Hmm still not working. Is someone (with experience) willing to check into my script via Teamviewer?