IS4Code / YSF

YSF Server Functions
Other
98 stars 34 forks source link

[Posibly]Set PlayerSpectate problem #93

Closed RaphaelCapone closed 5 years ago

RaphaelCapone commented 5 years ago

Hello, my server freezes since I use this plugin when the camera is moving or I think when SetPlayerSpectate or TogglePlayerSpectating functions is activated. Here is an exemple of command that freeze my server after using it:

CMD:spec(playerid, params[]) {

if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to login first.");
if(IsPlayerConnected(playerid))
{
    if(PlayerInfo[playerid][pAdmin] >= 1 || PlayerInfo[playerid][pHelper] >= 1)
    {
        new id,giveplayer[25],string[256],sendername[25];
        if(sscanf(params, "u", id)) return SCM(playerid,COLOR_WHITE,"{FFFFFF}Syntax: {FFFFFF}/spec <Name/Playerid>");
        {
            if(IsPlayerConnected(id))
            {
                if(id != INVALID_PLAYER_ID)
                {
                    if(Spectate[playerid] == -1)
                    {
                        if(SpecMePRO[id] == 1)return SCM(playerid, COLOR_YELLOW, "You  can't use this command on this player.");
                        BeforeSpectate[playerid][pState] = GetPlayerState(playerid);
                        BeforeSpectate[playerid][pWorld] = GetPlayerVirtualWorld(playerid);
                        BeforeSpectate[playerid][pInt] = GetPlayerInterior(playerid);
                        BeforeSpectate[playerid][pSpectating] = true;
                        new Float: x, Float: y, Float: z;
                        GetPlayerPos(playerid, x, y, z);
                        if(!IsPlayerInAnyVehicle(playerid))
                        {
                            BeforeSpectate[playerid][pOldPos][0] = x;
                            BeforeSpectate[playerid][pOldPos][1] = y;
                            BeforeSpectate[playerid][pOldPos][2] = z;
                        }
                        else
                            BeforeSpectate[playerid][pInVehicle] = GetPlayerVehicleID(playerid);
                    }
                    Spectate[playerid] = id;
                    new Float:health;
                    GetPlayerHealthEx(Spectate[playerid], health);
                    GetPlayerName(Spectate[playerid], giveplayer, sizeof(giveplayer));
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    if(reportreason[id] == 1)
                    {
                        format(string, sizeof(string), "Admin %s is now spectating %s (reported for being stuck).",sendername,giveplayer);
                    }
                    else if(reportreason[id] == 2)
                    {
                        format(string, sizeof(string), "Admin %s is now spectating %s (reported for DM).",sendername,giveplayer);
                    }
                    else if(reportreason[id] == 3 || AreCits[id] == 1 || HaveCheats[id] == 1)
                    {
                        format(string, sizeof(string), "Admin %s is now spectating %s (reported for cheats).",sendername,giveplayer);
                    }
                    ABroadCast(COLOR_YELLOW,string,1);
                    ReportTime[id] = 0;
                    format(reporttext[id], 30, "NULL");
                    reportcheater[id] = -1;
                    reportreason[id] = 0;
                    AreCits[id] = 0;
                    HaveCheats[id] = 0;
                    if(playerreported[id] != -1)
                    {
                        reportreason[playerreported[id]] = 0;
                    }
                    playerreported[id] = -1;
                    KillTimer(timerreport[id]);
                    AreCits[id] = 0;
                    new county[25];
                    GetPlayerCountry(playerid, county, sizeof(county));
                    format(string, sizeof(string), "(%d) %s | Level: %d | Health: %.0f | AFK: %d | Duty: %d | Ping: %d | FPS: %d | Country: %s",Spectate[playerid],giveplayer,PlayerInfo[Spectate[playerid]][pLevel],health,IsPlayerAFK[Spectate[playerid]],OnDuty[Spectate[playerid]],GetPlayerPing(Spectate[playerid]), PlayerInfo[playerid][pFPS], county);
                    SendClientMessage(playerid, COLOR_DARKPINK, string);
                    TogglePlayerSpectating(playerid, 1);
                    if(IsPlayerInAnyVehicle(Spectate[playerid]))
                    {
                        new carid = GetPlayerVehicleID(Spectate[playerid]);
                        PlayerSpectateVehicle(playerid, carid);
                        SpectateState[id] = 2;
                    }
                    else
                    {
                        PlayerSpectatePlayer(playerid, Spectate[playerid]);
                        SpectateState[id] = 1;
                    }
                    PlayerTextDrawSetString(playerid, TextDrawSpec[playerid][1], "LOADING...");
                    PlayerTextDrawShow(playerid, TextDrawSpec[playerid][1]);
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_WHITE, "{FFFFCC}The Player isn't connected");
            }
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_ERROR, AdminOnly);
        return 1;
    }
}
return 1;

}

Any clues? My server log dosn't print any crash, even if I'm using debugging mode on compile + crashdetect plugin. And yes, I put the last plugin on server.cfg EDIT: I don't think this is the last problem I have to my server after using this plugin... public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ) { if(PlayerInfo[playerid][pAdmin] > 0) { if (GetPlayerState(playerid) == 2) { new tmpcar = GetPlayerVehicleID(playerid); SetVehiclePos(tmpcar, fX, fY, fZ+5); } else { SetPlayerPosFindZ(playerid, fX, fY, fZ+5); } } if(PlayerInfo[playerid][pAdmin] > 0 && AdminDuty[playerid] == 1) { if (GetPlayerState(playerid) == 2) { new tmpcar = GetPlayerVehicleID(playerid); SetVehiclePos(tmpcar, fX, fY, fZ+5); } else { SetPlayerPosFindZ(playerid, fX, fY, fZ+5); } } if(IsPlayerInAnyVehicle(playerid)) { foreach(Player,i) { if(IsPlayerConnected(i)) { if(IsPlayerInVehicle(i, GetPlayerVehicleID(playerid))) { if(PlayerInfo2[i][pMember] == 15 && PlayerInfo2[playerid][pMember] != 14 || PlayerInfo2[i][pMember] == 12 && PlayerInfo2[playerid][pMember] != 12) { if(TransportDuty[i] == 1) { if(CP[i] > 1 || IsCollectingRubbish[i] > 1 || !IsATruck(GetPlayerVehicleID(i)) || MechanicCallTime[i] > 1 || CheckBus[i] > 1 || GotoMats[i] > 1 || CarJacker[i] > 1) { UsedFind[i] = 0; DisablePlayerCheckpoint(i); DisablePlayerRaceCheckpoint(i); CP[i] = 0; } SetPlayerCheckpoint(i, fX, fY, fZ, 4.0); CP[i] = 43; SCM(i, COLOR_LIGHTBLUE, "Pasagerul tau a ales destinatia dorita, urmeaza checkpoint-ul."); SCM(playerid, COLOR_LIGHTBLUE, "Ai setat locatia, asteapta ca taximetristul sa te duca acolo."); } } } } } } return 1; } Freezes when I teleport on the map...On foot(didn't tested with vehicle) UPDATED: my server crashes after 9-10 seconds...it's really weird :(..

RaphaelCapone commented 5 years ago

Hello, I see that only happens on my Linux server. It uses my all CPU when the server freezes. How can I fix that? Is possible any optimisation to this plugin? I have 1Core CPU and 1GB ram. Thanks..

IS4Code commented 5 years ago

Does it happen on R19 or R20-RC2?

RaphaelCapone commented 5 years ago

Yeah, it happens at the last release. I have to say that my server uses 10%+ CPU without YSF plugin(while with YSF 99,99% after few seconds or after using some commands like /spectate(freeze instantly) or /flymode(freezes after few secs)..)

RaphaelCapone commented 5 years ago

R20-RC2 version Also, I can't try with older versions becouse it gives me errors and crashes(like CreateGang functions or smth like that, I think it's becouse they support older version of samp or idk) On the latest version didn't give any warning/error

RaphaelCapone commented 5 years ago

If you want I can make a video to show my issue

RaphaelCapone commented 5 years ago

uh...nevermind, I updated beazones.inc and now it works normally I realize that I need to update an include after watching error logs on R19 version I think you can close the issue for the moment