SA-MP Forums Archive
Gate System crashing the Server - 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: Gate System crashing the Server (/showthread.php?tid=472071)



Gate System crashing the Server - damian123 - 26.10.2013

Hey, guys. I tried to convert the Gate system from zGaming to my MySQL gamemode and somehow everytime I use this command my server crashes:
pawn Код:
CMD:creategate(playerid, params[])
{
    new string[128], object;
    if(playerVariables[playerid][pAdminLevel] < 4) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    if(sscanf(params, "i", object)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /creategate [objectid]");
    for(new idx=1; idx<MAX_GATES; idx++)
    {
        if(!gatesVariables[idx][gModel])
        {
            GetPlayerPos(playerid, gatesVariables[idx][gCX], gatesVariables[idx][gCY], gatesVariables[idx][gCZ]);
            gatesVariables[idx][gModel] = object;
            gatesVariables[idx][gCX] = gatesVariables[idx][gCX] + 2;
            gatesVariables[idx][gCY] = gatesVariables[idx][gCY] + 2;
            gatesVariables[idx][gCRX] = 0;
            gatesVariables[idx][gCRY] = 0;
            gatesVariables[idx][gCRZ] = 0;
            GetPlayerPos(playerid, gatesVariables[idx][gOX], gatesVariables[idx][gOY], gatesVariables[idx][gOZ]);
            gatesVariables[idx][gOX] = gatesVariables[idx][gOX] + 2;
            gatesVariables[idx][gOY] = gatesVariables[idx][gOY] + 2;
            gatesVariables[idx][gORX] = 0;
            gatesVariables[idx][gORY] = 0;
            gatesVariables[idx][gORZ] = 0;
            gatesVariables[idx][gStatus] = 0;
            format(gatesVariables[idx][gPassword], 256, "");
            gatesVariables[idx][gSpeed] = 2;
            // Creating
            format(string, sizeof(string), "Gate ID: %d", idx);
            gatesVariables[idx][gGate] = CreateDynamicObject(gatesVariables[idx][gModel], gatesVariables[idx][gCX], gatesVariables[idx][gCY], gatesVariables[idx][gCZ], gatesVariables[idx][gCRX], gatesVariables[idx][gCRY], gatesVariables[idx][gCRZ]);
            gatesVariables[idx][gText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, gatesVariables[idx][gCX], gatesVariables[idx][gCY], gatesVariables[idx][gCZ], 10);
            // Text
            format(string, sizeof(string), "AdmWarn: %s has created gate ID %d. (Object: %d)", GetPlayerName(playerid), idx, object);
            submitToAdmins(string, COLOR_HOTORANGE);
            adminLog(string);
            idx = MAX_GATES;
        }
    }
    return 1;
}



Re: Gate System crashing the Server - Konstantinos - 26.10.2013

Download crashdetect plugin (version 4.12 - It can be found: https://github.com/Zeex/samp-plugin-...ases/tag/v4.12).

Then goto pawno folder and create a file pawn.cfg
Open the file and write in it:
pawn Код:
-d3
Save it and re-compile your files. Run the server and do what you did before (when the server crashed). The next time it'll crash the server (after done what I told you above), show us what it printed to the console/server log.


Re: Gate System crashing the Server - damian123 - 26.10.2013

That link is down


Re: Gate System crashing the Server - Konstantinos - 26.10.2013

My apologies.

https://github.com/Zeex/samp-plugin-...ases/tag/v4.12


Re: Gate System crashing the Server - damian123 - 26.10.2013

Thank you. I forgot to add a table, dumb me!


Re: Gate System crashing the Server - Pottus - 26.10.2013

You also need to put break; after this line idx = MAX_GATES; but I think your dynamic design is flawed to begin with I'll explain.

1.) You should have two functions CreateDynamicGate() and DestroyDynamicGate() this way you can call these functions instead of having to copy and paste code which I know you will.
2.) Don't use the modelid to check if a gate has been created initialize gatesVariables[idx][gGate] to -1 and use a #define #define INVALID_GATE_ID -1 Your way will still work but this will help readability.
3.) You don't know if these variables will be used new string[128], object; they should be placed after this line
if(!gatesVariables[idx][gModel]) not that it will really make any difference just a suggestion.