Gate System crashing the Server
#1

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;
}
Reply
#2

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.
Reply
#3

That link is down
Reply
#4

My apologies.

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

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

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)