SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 13/05/2019, 11:59 PM   #1
KinxpIn
Little Clucker
 
Join Date: Dec 2018
Posts: 25
Reputation: 0
Default BUG OnGameModeExit

Okay, so this is the problem.

Inside my GM, When OnGameModeExit runs, it will call OnPlayerDisconnect, now there is a saving system for the player's data&position in OnPlayerDisconnect.

When the player uses /q it will work Normally
When using /rcon exit it is also Normally

The question is, why only on
/rcon gmx or /gmx (custom cmd)
which is not normal?

PHP Code:
//OnGameModeExit
for (new 0GetPlayerPoolSize(); <= ji++)
    {
        if(
IsPlayerConnected(i))
        {
            
OnPlayerDisconnect(i1);
        }
    } 
PHP Code:
//OnPlayerDisconnect
OnStatusSave(playerid); //This will call saving system's stock 
PHP Code:
//GMX CUSTOM CMD
CMD:gmx(playeridparams[])
{
    if(
IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdmin] >= 10)
    {
        if (
restartcheck == 1) return SendClientMessage(playerid,COLOR_RED,"The server is already restarting!");
        
restartcheck 1;
        
SCMToAll(COLOR_ERROR"[! WARNING !] {808080}SERVER AKAN RESTART DALAM {FF0000}%i {808080}DETIK LAGI!"TIME);
        
SetTimer("ServerRestart"TIME*10000);
        
SetTimer("OTWRestart"50000);
        
SCMToAll(COLOR_ERROR"[! WARNING !] {FFFFFF}PLAYERS AKAN KELUAR DALAM {FF0000}5 {FFFFFF}DETIK LAGI!");
        
SCMToAll(COLOR_ERROR"[! WARNING !] {FFFFFF}SEMUA DATA AKAN DI SIMPAN BEBERAPA SAAT!");
    }
    else
    {
        
SendClientMessage(playeridCOLOR_SERVER"{FFFFFF}You are not authorized to use this command.");
    }
    return 
true;

KinxpIn is offline   Reply With Quote
Old 14/05/2019, 12:06 AM   #2
KinxpIn
Little Clucker
 
Join Date: Dec 2018
Posts: 25
Reputation: 0
Default Re: BUG OnGameModeExit

PS: No error log in MySQL, server_log, or Crashdetect. there works as usual
KinxpIn is offline   Reply With Quote
Old 14/05/2019, 07:52 AM   #3
Mugala
High-roller
 
Mugala's Avatar
 
Join Date: Nov 2012
Location: Georgia, Tbilisi
Posts: 1,160
Reputation: 73
Default Re: BUG OnGameModeExit

just use OnStatusSave(playerid) instead of calling OnPlayerDisconect.
__________________
Coding in 8 languages including Pawn, C#, C++ and SQL.
Available for hiring.

If you have a coding question or need an assistance in a code, just PM me.
If you want me to create something for you, here is a Discord Mugala#5651

Currently helping Community members in a coding.
Mugala is offline   Reply With Quote
Old 14/05/2019, 12:48 PM   #4
Koreadars
Big Clucker
 
Join Date: Mar 2019
Location: Czech Republic, Prdelákov.
Posts: 122
Reputation: 6
Default Re: BUG OnGameModeExit

If you need to use it:
CallLocalFunction("OnPlayerDisconnect", "i", i);
Koreadars is offline   Reply With Quote
Old 14/05/2019, 01:35 PM   #5
NaS
High-roller
 
NaS's Avatar
 
Join Date: Mar 2008
Location: 🇩🇪
Posts: 1,691
Reputation: 568
Default Re: BUG OnGameModeExit

OnPlayerDisconnect is called automatically when using GMX, changemode or exit. So you call it twice basically, it's not neccessary.

What exactly is not working? Is it saving nothing on GMX at all, or a wrong position?
NaS is offline   Reply With Quote
Old 14/05/2019, 01:37 PM   #6
GameOvr
Big Clucker
 
Join Date: Jun 2018
Posts: 148
Reputation: 0
Default Re: BUG OnGameModeExit

AFAIK u cant use any savings when gamemode is exiting. so if u have a custom command save data under the command and use a timer of 1 sec to close the server

TIP : use a repeating timer about 2min on gm init to save very inch of server data
__________________
Server Info :-
Host Name : ...::: Death Shadow CriticalWarZ :::...
Address : 173.249.49.62:7028
Mode : DSC v1.1: GW | ft. DM
Language : English

Description & Features :-
Gang Wars based server with default 6 gangs
Also there's a custom gang system
Featuring Death match (6 DMs)
Events like Gungame, LMS etc.
and much more ...

Discord : - https://discord.gg/Naudu9x
GameOvr is offline   Reply With Quote
Old 14/05/2019, 01:41 PM   #7
KinxpIn
Little Clucker
 
Join Date: Dec 2018
Posts: 25
Reputation: 0
Default Re: BUG OnGameModeExit

Quote:
Originally Posted by NaS View Post
OnPlayerDisconnect is called automatically when using GMX, changemode or exit. So you call it twice basically, it's not neccessary.

What exactly is not working? Is it saving nothing on GMX at all, or a wrong position?
It's saving but wrong position. (maybe 0,0,0)

Ok, so I have fixed this problem by making /gmx command with the relog system (banip & unbanip) before calling OnGameModeExit. so the data from the player will be stored safely 5 seconds before OnGameModeExit
KinxpIn is offline   Reply With Quote
Old 14/05/2019, 01:43 PM   #8
KinxpIn
Little Clucker
 
Join Date: Dec 2018
Posts: 25
Reputation: 0
Default Re: BUG OnGameModeExit

Quote:
Originally Posted by KinxpIn View Post
It's saving but wrong position. (maybe 0,0,0)

Ok, so I have fixed this problem by making /gmx command with the relog system (banip & unbanip) before calling OnGameModeExit. so the data from the player will be stored safely 5 seconds before OnGameModeExit
The point is this problem has been resolved in this way . But if the relog system is not used, the error will still appear as before
KinxpIn is offline   Reply With Quote
Old 14/05/2019, 01:48 PM   #9
KinxpIn
Little Clucker
 
Join Date: Dec 2018
Posts: 25
Reputation: 0
Default Re: BUG OnGameModeExit

Solved. Thank you for the answers and solutions from all of you
This is my GMX command:

PHP Code:
CMD:gmx(playeridparams[])
{
    if(
IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdmin] >= 10)
    {
        if (
restartcheck == 1) return SendClientMessage(playerid,COLOR_RED,"The server is already restarting!");
        
restartcheck 1;
        
SCMToAll(COLOR_ERROR"[! WARNING !] {808080}SERVER AKAN RESTART DALAM {FF0000}%i {808080}DETIK LAGI!"TIME);
        foreach(new 
Player)
        {
            
SetTimerEx("RelogSystem",5000,0,"i"i);
        }
        
SetTimer("ServerRestart"TIME*10000);
        
SCMToAll(COLOR_ERROR"[! WARNING !] {FFFFFF}PLAYERS AKAN KELUAR DALAM {FF0000}5 {FFFFFF}DETIK LAGI!");
        
SCMToAll(COLOR_ERROR"[! WARNING !] {FFFFFF}SEMUA DATA AKAN DI SIMPAN BEBERAPA SAAT!");
    }
    else
    {
        
SendClientMessage(playeridCOLOR_SERVER"{FFFFFF}You are not authorized to use this command.");
    }
    return 
true;
}

forward RelogSystem(playerid);
public 
RelogSystem(playerid)
{
    if(
IsPlayerConnected(playerid))
    {
        new 
string[64];
        new 
playerIP[32];
        
format(playerIP,sizeof(playerIP), "%s"GetPlayerIpEx(playerid));
        
format(ReconnectIP[playerid], MAX_IP_SIZE"%s"playerIP);
        
format(stringsizeof(string), "banip %s"playerIP);
        
SendRconCommand(string);
        
Reconnecting[playerid] = true;
        return 
1;
    }
    return 
1;
}

forward ServerRestart();
public 
ServerRestart()
{
    
SendRconCommand("gmx");
    for(new 
0<sizeof(FS); i++)
    {
        new 
string[32];
        
format(string,sizeof(string),"reloadfs %s",FS[i]);
        
SendRconCommand(string);
    }
    
restartcheck 0;
    return 
true;
}

public 
OnPlayerDisconnect(playeridreason)
{
    
//Blablabla
    
if(Reconnecting[playerid] == true)
    {
        new 
string[64];
        
format(stringsizeof(string), "unbanip %s"ReconnectIP[playerid]);
        
SendRconCommand(string);
        
Reconnecting[playerid] = false;
    }
    
OnStatusSave(playerid);

KinxpIn 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
OnGameModeExit - Help Sarra Scripting Help 4 13/08/2014 01:13 PM
OnGameModeExit AphexCCFC Scripting Help 9 09/04/2014 07:37 PM
OnGameModeExit Brokenbreaken Scripting Help 0 23/02/2013 10:49 PM
OnGameModeExit marquezsanchez Scripting Help 4 12/09/2012 05:54 PM
OnGameModeExit(); NeroX98 Scripting Help 6 10/06/2012 10:50 AM


All times are GMT. The time now is 05:45 AM.


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