What's Wrong?
#1

When i do /startEvent, and then /joinevent, It crashes my RCON and Server Shuts Down, There a Problem with that?

pawn Код:
if(strcmp(cmd, "/startevent", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if (PlayerInfo[playerid][pAdmin] >= 5 && (!EventStarted))
            {
                EventStarted = 1;
                EventLocked = 0;
                GetPlayerPos(playerid,ex,ey,ez);
                GetPlayerVirtualWorld(playerid);
                GetPlayerInterior(playerid);
                BroadCast(COLOR_LIGHTBLUE, "** Notice: An Event has started, use /joinevent.");
            }
            else if (PlayerInfo[playerid][pAdmin] >= 5 && (EventStarted))
            {
                EventStarted = 0;
            }
            else
            {
                SendClientMessage(playerid, COLOR_GRAD1, "   you are not authorized to use that command!");
            }
        }
        return 1;
    }
pawn Код:
if(strcmp(cmd, "/joinevent", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(EventStarted == 0)
            {
                  SendClientMessage(playerid, COLOR_LIGHTBLUE, " ** An Event has not Started.");
                  return 1;
            }
            else if(EventLocked == 1)
            {
                  SendClientMessage(playerid, COLOR_RED, "** The event is locked.");
                  return 1;
            }
            new EJoin = strval(tmp);
            new vw = GetPlayerVirtualWorld(playerid);
            SetPlayerPos(playerid,ex,ey,ez);
            SetPlayerVirtualWorld(playerid,vw);
            SetPlayerInterior(playerid,EventInfo[EJoin][EInterior]);
            PlayerInfo[playerid][pInt] = EventInfo[EJoin][EInterior];
        }
        return 1;
    }
Reply
#2

I can't find something wrong here.
Try to add some print function in your code and see which part of it crashes.
Reply
#3

Can you be a bit more specific? Do you receive any client messages before the server crashes? Is there any sort of delay between you typing the command and the server shutting down?

By overlooking the code, I see you are missing some code. You never assign the tmp variable to a value. You are missing something like so:
pawn Код:
tmp = strtok( cmdtext, idx );
Adding that after your check of whether or not the player is connected, will retrieve the first section of the string (cmdtext) after a space. For example, if you typed "/joinevent 55", the tmp variable would be assigned "55".

As for the server crashing, it could be due to the fact strval( ) is trying to retrieve a value that is either non-existent or is too big for it to handle. If I recall correctly, strval( ) can crash on large values. Try adding what I mentioned above, and come back with the results.

Also, as a tip, here are a couple things you should consider:
- Switching to ZCMD command processor
- Removing the IsPlayerConnected( ) checks from the commands

Switching to ZCMD would be a great thing for your mode, especially since you're using one of the slowest methods to execute the commands - strtok and strcmp - when you could be using ZCMD and sscanf2. Look them up, they are worth the time and effort to learn and convert to.

You also do not need the IsPlayerConnected( ) checks under OnPlayerCommandText callback, since now commands will simply not execute for non-connected players (Unless done by the script, I suppose).
Reply
#4

pawn Код:
if (PlayerInfo[playerid][pAdmin] >= 5 && (!EventStarted))
What's this line?
Try like this:
pawn Код:
if (PlayerInfo[playerid][pAdmin] >= 5 && EventStarted == 0)
EDIT:
pawn Код:
(EventStarted)
this
to this:
pawn Код:
EventStarted == 1
Reply
#5

I'm not sure what's crashing this, but I can tell you it's wrong. In your startevent command, you're not saving the players virtual world or interior to anything. In your joinevent command you're setting the player to the virtual world that he's already in and the command doesn't call for a parameter so strtok is being pointlessly used.
Reply
#6

Try this one.
pawn Код:
if(strcmp(cmd, "/startevent", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if (PlayerInfo[playerid][pAdmin] >= 5 && (!EventStarted))
            {
                EventStarted = 1;
                EventLocked = 0;
                new Float:ex, Float:ey, Float:ez;
                GetPlayerPos(playerid,ex,ey,ez);
                GetPlayerVirtualWorld(playerid);
                GetPlayerInterior(playerid);
                BroadCast(COLOR_LIGHTBLUE, "** Notice: An Event has started, use /joinevent.");
            }
            else if (PlayerInfo[playerid][pAdmin] >= 5 && (EventStarted))
            {
                EventStarted = 0;
            }
            else
            {
                SendClientMessage(playerid, COLOR_GRAD1, "   you are not authorized to use that command!");
            }
        }
        return 1;
    }
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)