GMX resets some player information & Death on spawn? Please help.
#1

Hi, I have been having two major bugs that are really annoying.

Im not sure if it's suppose to do this but apparently it's not so im wondering if anyone could let me know how to fix it.

1) When ever I do a gmx restart, players skins, xPos, yPos and zPos do not save and it's really annoying. I have no idea why it's happening as i am definitely saving the account info on OnPlayerDisconnect

2) When a player connects and logins, they get the 'spawn' option(which i want to remove too) and if they click it; they die.

What I need help with: GMX resetting some pInfo, and death on spawn.

If anyone could help me out that would be awesome
Thanks alot to anyone who replies.

Heres my pInfo enum
pawn Код:
enum pInfo
{
    pName[24],
    pPass,
    pCash,
    pSkin,
    pLevel,
    pVipLevel,
    pInt,
    pVW,
    pAdmin,
    aName[24],
    bool:HasSetAdminName,
    OnDuty,
    pSecKey,
    pKills,
    pDeaths,
    pGod,
    Float:pFacingAngle,
    Float:pHealth,
    Float:pArmour,
    Float:pLastX,
    Float:pLastY,
    Float:pLastZ,
    pFaction,
    pFRank
}
Heres my SaveAccountInfo function:
pawn Код:
public SaveAccountInfo(playerid)
{
    new cash = GetPlayerMoney(playerid);
    new skin = GetPlayerSkin(playerid);
    new level = GetPlayerScore(playerid);
    new inter = GetPlayerInterior(playerid);
    new vw = GetPlayerVirtualWorld(playerid);
    PlayerInfo[playerid][OnDuty] = false;
    new Float:X, Float:Y, Float:Z;
    new Float:facingangle;
    new Float:health, Float:armour;
   
    new faction, rank;
    faction = PlayerInfo[playerid][pFaction];
    rank = PlayerInfo[playerid][pFRank];
    GetPlayerHealth(playerid, health);
    GetPlayerArmour(playerid, armour);
    GetPlayerFacingAngle(playerid, facingangle);
    GetPlayerPos(playerid, X, Y, Z);
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteString(File,"pName", PlayerInfo[playerid][pName]);
    INI_WriteInt(File,"Cash",cash);
    INI_WriteInt(File,"Skin",skin);
    INI_WriteInt(File,"Level",level);
    INI_WriteInt(File,"Vip", PlayerInfo[playerid][pVipLevel]);
    INI_WriteInt(File,"Int",inter);
    INI_WriteInt(File,"VW",vw);
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteString(File,"AdminName", PlayerInfo[playerid][aName]);
    INI_WriteBool(File,"HasSetAdminName", PlayerInfo[playerid][HasSetAdminName]);
    INI_WriteInt(File,"SecKey",PlayerInfo[playerid][pSecKey]);
    INI_WriteInt(File,"OnDuty",PlayerInfo[playerid][OnDuty]);
    //INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    //INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteFloat(File, "Health", health);
    INI_WriteFloat(File, "Armour", armour);
    INI_WriteFloat(File, "FacingAngle", facingangle);
    INI_WriteFloat(File, "LastX", X);
    INI_WriteFloat(File, "LastY", Y);
    INI_WriteFloat(File, "LastZ", Z);
    INI_WriteInt(File, "Faction", faction);
    INI_WriteInt(File, "Rank", rank);

    INI_Close(File);
    return 1;
}
OnPlayerConnect
pawn Код:
public OnPlayerConnect(playerid)
{
    SetPlayerCameraPos(playerid, 260.9846, -2048.4597, 99.0365);
    SetPlayerCameraLookAt(playerid, 261.6099, -2047.6786, 98.8322);
    SendClientMessage(playerid, COLOR_BLUE, "Current version: "SERVER_VERSION"");
    SendClientMessage(playerid, COLOR_LIGHTBLUE, "Type /(h)elp for a list of helpful commands!");
    SetPlayerColor(playerid, COLOR_WHITE);
    PlayerInfo[playerid][OnDuty] = false;
    PlayerInfo[playerid][pGod] = 0;
    //Anti Dual Wield.
    SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL, 0);
    SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, 0);
    SetPlayerSkillLevel(playerid, WEAPONSKILL_MICRO_UZI, 0);
    gPlayerLogged[playerid] = 0;
    Seatbelt[playerid] = 0;
    new string[128];
    if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid,2,DIALOG_STYLE_PASSWORD,"Login","Welcome back to Emerald Isle Roleplay.\n\nThat name is registered. Please enter your password below.","Login","Quit"); //login
        format(string, sizeof(string), ""COL_WHITE"Welcome back to "COL_WHITE"Emerald Isle Roleplay, "COL_WHITE"%s!", GetPlayerFirstName(playerid));
        SendClientMessage(playerid, -1, string);
    }
    else
    {
        ShowPlayerDialog(playerid,1,DIALOG_STYLE_PASSWORD,"Register","Welcome to Emerald Isle Roleplay.\n\nPlease register your account by typing the password below.","Register","Quit");
        format(string, sizeof(string), ""COL_WHITE"Welcome to "COL_WHITE"Emerald Isle Roleplay, "COL_WHITE"%s!", GetPlayerFirstName(playerid));
        SendClientMessage(playerid, -1, string);
    }
    if(!IsValidName(playerid) && !IsPlayerNPC(playerid) && PlayerInfo[playerid][pAdmin] < 2)
    {
        format(string, sizeof(string), "AdmCmd: %s has been kicked by NameChecker, reason: Invalid name format.", GetName(playerid));
        SendClientMessage(playerid, COLOR_LIGHTRED, "You've been kicked by NameChecker, reason: Invalid name format. (Firstname_Lastname)");
        Kick(playerid);
    }
   
    SetPlayerInterior(playerid,0);
    TogglePlayerSpectating(playerid, 0);
    gPlayerLogged[playerid] = 1;
    return 1;
}
Heres my OnPlayerDisconnect()
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    PlayerInfo[playerid][pGod] = 0;
    new discstring[128];
    switch(reason)
    {
        case 0: format(discstring, sizeof(discstring), "* %s has left the server. (Timeout)", GetName(playerid));
        case 1: format(discstring, sizeof(discstring), "* %s has left the server. (Leaving)", GetName(playerid));
        case 2: format(discstring, sizeof(discstring), "* %s has left the server. (Kicked)", GetName(playerid));
    }
    ProxDetector(20.0, playerid, discstring, COLOR_YELLOW, COLOR_YELLOW, COLOR_YELLOW, COLOR_YELLOW, COLOR_YELLOW);
    PlayerInfo[playerid][OnDuty] = false;
    SaveAccountInfo(playerid);
    return 1;
}
Reply
#2

Make sure under the command GMX you set it to SaveAccountInfo for everyone using a foreach function.
Reply
#3

pawn Код:
CMD:gmx(playerid)
{
    SaveStats(playerid);
     SetTimer("Restart", 1000, false);
}

forward Restart();
public Restart()
{
     SendRconCommand(gmx);
}
pawn Код:
stock SaveStats(playerid)
{
    new cash = GetPlayerMoney(playerid);
    new skin = GetPlayerSkin(playerid);
    new level = GetPlayerScore(playerid);
    new inter = GetPlayerInterior(playerid);
    new vw = GetPlayerVirtualWorld(playerid);
    PlayerInfo[playerid][OnDuty] = false;
    new Float:X, Float:Y, Float:Z;
    new Float:facingangle;
    new Float:health, Float:armour;
    new faction, rank;
    faction = PlayerInfo[playerid][pFaction];
    rank = PlayerInfo[playerid][pFRank];
    GetPlayerHealth(playerid, health);
    GetPlayerArmour(playerid, armour);
    GetPlayerFacingAngle(playerid, facingangle);
    GetPlayerPos(playerid, X, Y, Z);
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteString(File,"pName", PlayerInfo[playerid][pName]);
    INI_WriteInt(File,"Cash",cash);
    INI_WriteInt(File,"Skin",skin);
    INI_WriteInt(File,"Level",level);
    INI_WriteInt(File,"Vip", PlayerInfo[playerid][pVipLevel]);
    INI_WriteInt(File,"Int",inter);
    INI_WriteInt(File,"VW",vw);
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteString(File,"AdminName", PlayerInfo[playerid][aName]);
    INI_WriteBool(File,"HasSetAdminName", PlayerInfo[playerid][HasSetAdminName]);
    INI_WriteInt(File,"SecKey",PlayerInfo[playerid][pSecKey]);
    INI_WriteInt(File,"OnDuty",PlayerInfo[playerid][OnDuty]);
    //INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    //INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteFloat(File, "Health", health);
    INI_WriteFloat(File, "Armour", armour);
    INI_WriteFloat(File, "FacingAngle", facingangle);
    INI_WriteFloat(File, "LastX", X);
    INI_WriteFloat(File, "LastY", Y);
    INI_WriteFloat(File, "LastZ", Z);
    INI_WriteInt(File, "Faction", faction);
    INI_WriteInt(File, "Rank", rank);
    INI_Close(File);
    return 1;
}
Correct me if I am wrong?
Reply
#4

Thanks for the replies

Should this be working?

Edit: Doesn't work I still spawn with skin 299, and at grid 1529.6000,-1691.2000,13.3828
Even if i remove AddPlayerClass(299, 1529.6, -1691.2, 13.3, 90.0, 0, 0, 0, 0, 0, 0); from OnGameModeInit(), i still spawn there when i log in

pawn Код:
CMD:restart(playerid)
{
    if(PlayerInfo[playerid][pAdmin] <1) return SCM(playerid,COLOR_WHITE,"You are not authorized to do that!");
    if(PlayerInfo[playerid][pAdmin] <4) return SCM(playerid,COLOR_WHITE,"You need to be a higher level administrator!");
    if(PlayerInfo[playerid][pAdmin] >=1337)
    {
        foreach(Player, id)
        {
             SaveStats(playerid);
        }
        SetTimer(#Restart, 1 * 1000, 0);
    }
    return 1;
}
Reply
#5

GMX also causes client bugs you should know, I would never rely on it.
Reply
#6

Is there a better way of reloading the GM?
Reply
#7

Stop and restart the server there is a way to set this automatically on linux....

This restarts the server automatically when it's shutdown which in my opinion is far easier than toiling with OnGameModeExit() and will avoid client bugs.

Filename: starter-stoner.sh

Код:
#!/bin/sh
log=samp.log
dat=`date`
samp="samp-stoner"
dir="."
cd $dir
 
echo "${dat} watchdog script starting." >>${log}
while true; do
        echo "${dat} Server exited, restarting..." >>${log}
        mv $dir/server_log.txt $dir/logs/server_log.`date '+%m%d%y%H%M%S'`
        $dir/$samp >> $log
	sleep 2
done
Reply
#8

Im using windows thanks though

I fixed the death on spawn. I think my positions actually save, they just dont load :S
Reply
#9

With GMX, OnFilterScriptExit gets called first or something like that, without player disconnecting being called, (I guess, it was something like that), download ******'s fixes include to fix this - and do read the topic well.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)