SA-MP Forums Archive
Too many bugs. - 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: Too many bugs. (/showthread.php?tid=404752)



Too many bugs. - Huxley - 04.01.2013

Hi everyone.

Me, and my friends tried my server and there were a lot of bugs. I don't know which one to solve, one of the most common happened bugs was: objects/vehicles/players blinking or disappearing.

I have searched everywhere in the script how to fix it, but I'm lost and I gave up. That's the reason I came here to request for help to solve this issue. I will show the codes in OnPlayerSpawn callback.

pawn Код:
public OnPlayerSpawn(playerid)
{
    PlayerPlaySound(playerid,1063,0.0,0.0,0.0);
    SetPlayerToTeamColor(playerid);
    IsSpawned[playerid] =1;
    SetCameraBehindPlayer(playerid);
    TextDrawShowForPlayer(playerid, LocationTD);
    SetPlayerVirtualWorld(playerid, 0);
    SetPlayerInterior(playerid, 0);
   
    if(IsBeingSpeced[playerid] == 1)
    {
        foreach(Player,i)
        {
            if(spectatorid[i] == playerid)
            {
                PlayerSpectatePlayer(i, playerid);
            }
        }
        return 1;
    }

    if(gTeam[playerid] == TEAM_COP)
    {
        new rnd = random(sizeof(PoliceSpawnPoints));
        SetPlayerPos(playerid, PoliceSpawnPoints[rnd][0], PoliceSpawnPoints[rnd][1], PoliceSpawnPoints[rnd][2]);
        SetPlayerFacingAngle(playerid, PoliceSpawnPoints[rnd][3]);

        GivePlayerWeapon(playerid, 3, 1);
        GivePlayerWeapon(playerid, 22, 500);
        GivePlayerWeapon(playerid, 29, 900);
        SetPlayerArmour(playerid, 35);
        ShowPlayerDialog(playerid, DIALOG_JOB, DIALOG_STYLE_MSGBOX, "Police Officer", "{FFFFFF}You have been spawned as a police officer. As a police officer, your job is to keep the city clean from criminals. \nYou can refer to your commands by using /cmds \nPlease abide by the server rules and enjoy.","Okay","");
        return 1;
    }
    if(gTeam[playerid] == TEAM_UNCOVER)
    {
        if(GetPlayerScore(playerid) < 500)
        {
            new string[128];
            ForceClassSelection(playerid);
            TogglePlayerSpectating(playerid, true);
            TogglePlayerSpectating(playerid, false);
            SendClientMessage(playerid, COLOR_ERROR, "[ERROR]: {FFFFFF}You cannot use this class.");

            foreach(Player, i)
            {
                if(pInfo[i][pAdmin] >= 1)
                {
                    format(string,sizeof(string),"[ATTEMPTION]: {FFFFFF}%s(%d) has tried to use a restricted class.",PlayerName(playerid),playerid);
                    SendClientMessage(i, COLOR_ERROR, string);
                }
            }
            return 1;
        }
        new rnd = random(sizeof(PoliceSpawnPoints));
        SetPlayerPos(playerid, PoliceSpawnPoints[rnd][0], PoliceSpawnPoints[rnd][1], PoliceSpawnPoints[rnd][2]);
        SetPlayerFacingAngle(playerid, PoliceSpawnPoints[rnd][3]);

        GivePlayerWeapon(playerid, 3, 1);
        GivePlayerWeapon(playerid, 24, 1500);
        GivePlayerWeapon(playerid, 25, 1000);
        GivePlayerWeapon(playerid, 29, 2000);
        GivePlayerWeapon(playerid, 34, 500);
        SetPlayerArmour(playerid, 75);
        ShowPlayerDialog(playerid, DIALOG_JOB, DIALOG_STYLE_MSGBOX, "Undercover Agent", "{FFFFFF}You have been spawned as an undercover agent. As an undercover agent, your job is to keep the city clean from criminals. \nYou can refer to your commands by using /cmds \nPlease abide by the server rules and enjoy.","Okay","");
        return 1;
    }
    if(gTeam[playerid] == TEAM_ARMY)
    {
        if(pInfo[playerid][pArmy] == 0)
        {
            new string[128];
            ForceClassSelection(playerid);
            TogglePlayerSpectating(playerid, true);
            TogglePlayerSpectating(playerid, false);
            SendClientMessage(playerid, COLOR_ERROR, "[ERROR]: {FFFFFF}You cannot use this class.");

            foreach(Player, i)
            {
                if(pInfo[i][pAdmin] >= 1)
                {
                    format(string,sizeof(string),"[ATTEMPTION]: {FFFFFF}%s(%d) has tried to use a restricted class.",PlayerName(playerid),playerid);
                    SendClientMessage(i, COLOR_ERROR, string);
                }
            }
            return 1;
        }
        SetPlayerPos(playerid, 2772.5273,-2396.6892,13.6328);
        SetPlayerFacingAngle(playerid, 93.7168);

        GivePlayerWeapon(playerid, 4, 1);
        GivePlayerWeapon(playerid, 24, 1500);
        GivePlayerWeapon(playerid, 27, 1500);
        GivePlayerWeapon(playerid, 29, 1900);
        GivePlayerWeapon(playerid, 31, 1500);
        GivePlayerWeapon(playerid, 34, 1000);
        GivePlayerWeapon(playerid, 41, 5000);
        SetPlayerArmour(playerid, 100);
        ShowPlayerDialog(playerid, DIALOG_JOB, DIALOG_STYLE_MSGBOX, "Army officer", "{FFFFFF}You have been spawned as an army officer. As an army officer, your job is to keep the city clean from criminals and assist other police officers. \nYou can refer to your commands by using /cmds \nPlease abide by the server rules and enjoy.","Okay","");
        return 1;
    }
    if(gTeam[playerid] == TEAM_SWAT)
    {
        if(pInfo[playerid][pSwat] == 0)
        {
            new string[128];
            ForceClassSelection(playerid);
            TogglePlayerSpectating(playerid, true);
            TogglePlayerSpectating(playerid, false);
            SendClientMessage(playerid, COLOR_ERROR, "[ERROR]: {FFFFFF}You cannot use this class.");

            foreach(Player, i)
            {
                if(pInfo[i][pAdmin]>=1)
                {
                    format(string,sizeof(string),"[ATTEMPTION]: {FFFFFF}%s(%d) has tried to use a restricted class.",PlayerName(playerid),playerid);
                    SendClientMessage(i, COLOR_ERROR, string);
                }
            }
            return 1;
        }
        new rnd = random(sizeof(PoliceSpawnPoints));
        SetPlayerPos(playerid, PoliceSpawnPoints[rnd][0], PoliceSpawnPoints[rnd][1], PoliceSpawnPoints[rnd][2]);
        SetPlayerFacingAngle(playerid, PoliceSpawnPoints[rnd][3]);

        GivePlayerWeapon(playerid, 24, 1500);
        GivePlayerWeapon(playerid, 29, 1900);
        GivePlayerWeapon(playerid, 31, 1500);
        GivePlayerWeapon(playerid, 34, 1000);
        GivePlayerWeapon(playerid, 41, 5000);
        SetPlayerArmour(playerid, 100);
        ShowPlayerDialog(playerid, DIALOG_JOB, DIALOG_STYLE_MSGBOX, "S.W.A.T. officer", "{FFFFFF}You have been spawned as a SWAT officer. As a SWAT officer, your job is to keep the city clean from criminals and assist other police officers. \nYou can refer to your commands by using /cmds \nPlease abide by the server rules and enjoy.","Okay","");
        return 1;
    }
    if(gTeam[playerid] == TEAM_MEDIC)
    {
        new rnd = random(sizeof(MedicSpawnPoints));
        SetPlayerPos(playerid, MedicSpawnPoints[rnd][0], MedicSpawnPoints[rnd][1], MedicSpawnPoints[rnd][2]);
        SetPlayerFacingAngle(playerid, MedicSpawnPoints[rnd][3]);

        GivePlayerWeapon(playerid, 22, 34);
        SetPlayerArmour(playerid, 50);
        ShowPlayerDialog(playerid, DIALOG_JOB, DIALOG_STYLE_MSGBOX, "Paramedic", "{FFFFFF}You have been spawned as a paramedic. As a paramedic, your job is to make sure everyone's health is secured. \nYou can refer to your commands by using /cmds \nPlease abide by the server rules and enjoy.","Okay","");
        return 1;
    }
    if(gTeam[playerid] == TEAM_MECHANIC)
    {
        new rnd = random(sizeof(MecSpawnPoints));
        SetPlayerPos(playerid, MecSpawnPoints[rnd][0], MecSpawnPoints[rnd][1], MecSpawnPoints[rnd][2]);
        SetPlayerFacingAngle(playerid, MecSpawnPoints[rnd][3]);

        GivePlayerWeapon(playerid, 22, 68);
        ShowPlayerDialog(playerid, DIALOG_JOB, DIALOG_STYLE_MSGBOX, "Vehicle Mechanic", "{FFFFFF}You have been spawned as a mechanic. As a mechanic, your job is to repair any player's vehicle (if they called for your service). \nYou can refer to your commands by using /cmds \nPlease abide by the server rules and enjoy.","Okay","");
        return 1;
    }
    if(gTeam[playerid] == TEAM_CIVDEF)
    {
        if(GetPlayerScore(playerid) < 350)
        {
            new string[128];
            ForceClassSelection(playerid);
            TogglePlayerSpectating(playerid, true);
            TogglePlayerSpectating(playerid, false);
            SendClientMessage(playerid, COLOR_ERROR, "[ERROR]: {FFFFFF}You cannot use this class.");

            foreach(Player, i)
            {
                if(pInfo[i][pAdmin]>=1)
                {
                    format(string,sizeof(string),"[ATTEMPTION]: {FFFFFF}%s(%d) has tried to use a restricted class.",PlayerName(playerid),playerid);
                    SendClientMessage(i, COLOR_ERROR, string);
                }
            }
            return 1;
        }
        new rnd = random(sizeof(SESpawnPoints));
        SetPlayerPos(playerid, SESpawnPoints[rnd][0], SESpawnPoints[rnd][1], SESpawnPoints[rnd][2]);
        SetPlayerFacingAngle(playerid, SESpawnPoints[rnd][3]);

        GivePlayerWeapon(playerid, 3, 1);
        GivePlayerWeapon(playerid, 22, 500);
        GivePlayerWeapon(playerid, 29, 900);
        SetPlayerArmour(playerid, 35);
        ShowPlayerDialog(playerid, DIALOG_JOB, DIALOG_STYLE_MSGBOX, "Civil Defense", "{FFFFFF}You have been spawned as a Civil Defense officer. As a Civil Defense officer, your job is to assist other law enforcers and protect civilians from getting harmed. \nNOTE: You are allowed to shoot on players who are trying to kill other player. \nYou can refer to your commands by using /cmds \nPlease abide by the server rules and enjoy.","Okay","");
        return 1;
    }
    if(gTeam[playerid] == TEAM_CIVILIAN)
    {
        new rnd = random(sizeof(CivSpawnPoints));
        SetPlayerPos(playerid, CivSpawnPoints[rnd][0], CivSpawnPoints[rnd][1], CivSpawnPoints[rnd][2]);
        SetPlayerFacingAngle(playerid, CivSpawnPoints[rnd][3]);

        GivePlayerWeapon(playerid, 22, 100);
        GivePlayerWeapon(playerid, 28, 100);
        ShowPlayerDialog(playerid, DIALOG_CIVJOB, DIALOG_STYLE_LIST, "Civilian - Choose a job", "{FFFFFF}Rapist \nWeapon dealer \nDrug dealer \nAssassin \nTerrorist","Select","");
        return 1;
    }
    if(AdminJail[playerid] >=1)
    {
        new string[128];

        SetPlayerPos(playerid, 226.9409,1758.1250,1001.3290);
        SetPlayerFacingAngle(playerid, 265.8869);
        SetPlayerVirtualWorld(playerid, 10);
        SetPlayerInterior(playerid, 1);
        ResetPlayerWeapons(playerid);
        TogglePlayerControllable(playerid, false);
        SetTimerEx("InteriorEntered", 5000, false, "i", playerid);
        SetTimerEx("AdminJailed", 1000, false, "i", playerid);

        format(string,sizeof(string),"~b~admin jail ~n~~w~%d seconds left",AdminJail[playerid]);
        GameTextForPlayer(playerid, string, 1100, 6);

        format(string,sizeof(string),"[SYSTEM] {FFFFFF}%s {00B2EE}has been automatically sent to admin jail. Reason: {FFFFFF}Left while in jail.",PlayerName(playerid));
        SendClientMessageToAll(COLOR_LIGHTBLUE2, string);
        return 1;
    }
    if(!gPlayerAnimLibsPreloaded[playerid])
    {
        PreloadAnimLib(playerid,"AIRPORT");
        PreloadAnimLib(playerid,"Attractors");
        PreloadAnimLib(playerid,"BAR");
        PreloadAnimLib(playerid,"BASEBALL");
        PreloadAnimLib(playerid,"BD_FIRE");
        PreloadAnimLib(playerid,"benchpress");
        PreloadAnimLib(playerid,"BF_injection");
        PreloadAnimLib(playerid,"BIKED");
        PreloadAnimLib(playerid,"BIKEH");
        PreloadAnimLib(playerid,"BIKELEAP");
        PreloadAnimLib(playerid,"BIKES");
        PreloadAnimLib(playerid,"BIKEV");
        PreloadAnimLib(playerid,"BIKE_DBZ");
        PreloadAnimLib(playerid,"BMX");
        PreloadAnimLib(playerid,"BOX");
        PreloadAnimLib(playerid,"BSKTBALL");
        PreloadAnimLib(playerid,"BUDDY");
        PreloadAnimLib(playerid,"BUS");
        PreloadAnimLib(playerid,"CAMERA");
        PreloadAnimLib(playerid,"CAR");
        PreloadAnimLib(playerid,"CAR_CHAT");
        PreloadAnimLib(playerid,"CASINO");
        PreloadAnimLib(playerid,"CHAINSAW");
        PreloadAnimLib(playerid,"CHOPPA");
        PreloadAnimLib(playerid,"CLOTHES");
        PreloadAnimLib(playerid,"COACH");
        PreloadAnimLib(playerid,"COLT45");
        PreloadAnimLib(playerid,"COP_DVBYZ");
        PreloadAnimLib(playerid,"CRIB");
        PreloadAnimLib(playerid,"DAM_JUMP");
        PreloadAnimLib(playerid,"DANCING");
        PreloadAnimLib(playerid,"DILDO");
        PreloadAnimLib(playerid,"DODGE");
        PreloadAnimLib(playerid,"DOZER");
        PreloadAnimLib(playerid,"DRIVEBYS");
        PreloadAnimLib(playerid,"FAT");
        PreloadAnimLib(playerid,"FIGHT_B");
        PreloadAnimLib(playerid,"FIGHT_C");
        PreloadAnimLib(playerid,"FIGHT_D");
        PreloadAnimLib(playerid,"FIGHT_E");
        PreloadAnimLib(playerid,"FINALE");
        PreloadAnimLib(playerid,"FINALE2");
        PreloadAnimLib(playerid,"Flowers");
        PreloadAnimLib(playerid,"FOOD");
        PreloadAnimLib(playerid,"Freeweights");
        PreloadAnimLib(playerid,"GANGS");
        PreloadAnimLib(playerid,"GHANDS");
        PreloadAnimLib(playerid,"GHETTO_DB");
        PreloadAnimLib(playerid,"goggles");
        PreloadAnimLib(playerid,"GRAFFITI");
        PreloadAnimLib(playerid,"GRAVEYARD");
        PreloadAnimLib(playerid,"GRENADE");
        PreloadAnimLib(playerid,"GYMNASIUM");
        PreloadAnimLib(playerid,"HAIRCUTS");
        PreloadAnimLib(playerid,"HEIST9");
        PreloadAnimLib(playerid,"INT_HOUSE");
        PreloadAnimLib(playerid,"INT_OFFICE");
        PreloadAnimLib(playerid,"INT_SHOP");
        PreloadAnimLib(playerid,"JST_BUISNESS");
        PreloadAnimLib(playerid,"KART");
        PreloadAnimLib(playerid,"KISSING");
        PreloadAnimLib(playerid,"KNIFE");
        PreloadAnimLib(playerid,"LAPDAN1");
        PreloadAnimLib(playerid,"LAPDAN2");
        PreloadAnimLib(playerid,"LAPDAN3");
        PreloadAnimLib(playerid,"LOWRIDER");
        PreloadAnimLib(playerid,"MD_CHASE");
        PreloadAnimLib(playerid,"MEDIC");
        PreloadAnimLib(playerid,"MD_END");
        PreloadAnimLib(playerid,"MISC");
        PreloadAnimLib(playerid,"MTB");
        PreloadAnimLib(playerid,"MUSCULAR");
        PreloadAnimLib(playerid,"NEVADA");
        PreloadAnimLib(playerid,"ON_LOOKERS");
        PreloadAnimLib(playerid,"OTB");
        PreloadAnimLib(playerid,"PARACHUTE");
        PreloadAnimLib(playerid,"PARK");
        PreloadAnimLib(playerid,"PAULNMAC");
        PreloadAnimLib(playerid,"PED");
        PreloadAnimLib(playerid,"PLAYER_DVBYS");
        PreloadAnimLib(playerid,"PLAYIDLES");
        PreloadAnimLib(playerid,"POLICE");
        PreloadAnimLib(playerid,"POOL");
        PreloadAnimLib(playerid,"POOR");
        PreloadAnimLib(playerid,"PYTHON");
        PreloadAnimLib(playerid,"QUAD");
        PreloadAnimLib(playerid,"QUAD_DBZ");
        PreloadAnimLib(playerid,"RIFLE");
        PreloadAnimLib(playerid,"RIOT");
        PreloadAnimLib(playerid,"ROB_BANK");
        PreloadAnimLib(playerid,"ROCKET");
        PreloadAnimLib(playerid,"RUSTLER");
        PreloadAnimLib(playerid,"RYDER");
        PreloadAnimLib(playerid,"SCRATCHING");
        PreloadAnimLib(playerid,"SHAMAL");
        PreloadAnimLib(playerid,"SHOTGUN");
        PreloadAnimLib(playerid,"SILENCED");
        PreloadAnimLib(playerid,"SKATE");
        PreloadAnimLib(playerid,"SPRAYCAN");
        PreloadAnimLib(playerid,"STRIP");
        PreloadAnimLib(playerid,"SUNBATHE");
        PreloadAnimLib(playerid,"SWAT");
        PreloadAnimLib(playerid,"SWEET");
        PreloadAnimLib(playerid,"SWIM");
        PreloadAnimLib(playerid,"SWORD");
        PreloadAnimLib(playerid,"TANK");
        PreloadAnimLib(playerid,"TATTOOS");
        PreloadAnimLib(playerid,"TEC");
        PreloadAnimLib(playerid,"TRAIN");
        PreloadAnimLib(playerid,"TRUCK");
        PreloadAnimLib(playerid,"UZI");
        PreloadAnimLib(playerid,"VAN");
        PreloadAnimLib(playerid,"VENDING");
        PreloadAnimLib(playerid,"VORTEX");
        PreloadAnimLib(playerid,"WAYFARER");
        PreloadAnimLib(playerid,"WEAPONS");
        PreloadAnimLib(playerid,"WUZI");
        PreloadAnimLib(playerid,"SNM");
        PreloadAnimLib(playerid,"BLOWJOBZ");
        PreloadAnimLib(playerid,"SEX");
        PreloadAnimLib(playerid,"BOMBER");
        PreloadAnimLib(playerid,"RAPPING");
        PreloadAnimLib(playerid,"SHOP");
        PreloadAnimLib(playerid,"BEACH");
        PreloadAnimLib(playerid,"SMOKING");
        PreloadAnimLib(playerid,"FOOD");
        PreloadAnimLib(playerid,"ON_LOOKERS");
        PreloadAnimLib(playerid,"DEALER");
        PreloadAnimLib(playerid,"CRACK");
        PreloadAnimLib(playerid,"CARRY");
        PreloadAnimLib(playerid,"COP_AMBIENT");
        PreloadAnimLib(playerid,"PARK");
        PreloadAnimLib(playerid,"INT_HOUSE");
        PreloadAnimLib(playerid,"FOOD");
        gPlayerAnimLibsPreloaded[playerid] = 1;
        return 1;
    }
    return 1;
}
Another thing; Players kept spawning at the Las Venturas hotel suite (the one in front of AutoBahn near Royal Casino) after died. At first they spawned at random spawn points I've set, after they died, they spawn in middle of nowhere in Las Venturas.

About the blinking players/stuffs; Me and other players were in virtual world 0 and interior 0, which were same. But the only thing that is really making me angry is, the other players kept blinking and disappearing, they also complain that it happens on myself too, considering it happened to everyone.

Please, if you can help me, then do it. I don't mind if it's taking a long time, as long as I can solve this.

Thanks for reading. Regards.


Re: Too many bugs. - RajatPawar - 04.01.2013

I am sorry if this is right and I am wrong, but what's this? I saw this being coded everywhere.
pawn Код:
TogglePlayerSpectating(playerid, true);
            TogglePlayerSpectating(playerid, false);



Re: Too many bugs. - Huxley - 04.01.2013

It was actually to send the player back to class selection without killing the player. Does it bugs the gameplay or something?