[Help]Small Issue
#1

I'm developing a /drag command for my roleplay server and it works good. The only problem is that the script cancels itself when the variable is played? I'll explain...


pawn Код:
enum CopDrag // Group variables for copdrag.
{
    Cop, // If this group variable is set to 1 that means the cop is dragging someone.
    Crim, // If this group variable is set it means the criminal is being dragged.
    CopPlayer[MAX_PLAYERS], // This is sets a variable on the cop to the id of the player they are dragging.
    CrimPlayer[MAX_PLAYERS], // This sets a variable on the criminal to the id of the cop that is dragging them.
};
new Drag[MAX_PLAYERS][CopDrag];
This is the Enum I made.


pawn Код:
DragStop(copid, crimid)
{
    Drag[copid][Cop] = 0;
    Drag[crimid][Crim] = 0;
    Drag[copid][CopPlayer] = INVALID_PLAYER_ID;
    Drag[crimid][CrimPlayer] = INVALID_PLAYER_ID;
    KillTimer(DragTimer[crimid]);
}
This is the function I made.

My problem is when I use them in a command. For example...
pawn Код:
CMD:unfreeze(playerid, params[])
{
    if (PlayerInfo[playerid][pAdmin] >= 2)
    {
        new string[128], giveplayerid;
        if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /unfreeze [playerid]");


        if(IsPlayerConnected(giveplayerid))
        {
            DeletePVar(giveplayerid, "IsFrozen");
            TogglePlayerControllable(giveplayerid, 1);
            DragStop(Drag[giveplayerid][CrimPlayer], giveplayerid); // Script stops here!
            format(string, sizeof(string), "AdmCmd: %s was unfrozen by %s.",GetPlayerNameEx(giveplayerid),GetPlayerNameEx(playerid));
            ABroadCast(COLOR_LIGHTRED,string,2);
        }
        else
        {
            SendClientMessageEx(playerid, COLOR_WHITE, "Invalid player specified.");
        }

    }
    else
    {
        SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
    }
    return 1;
}
The script stops where I played my function "DragStop". So it will unfreeze the player but the part where it shows the text won't play. It says "unknown command". I thought it was an issue with the way I made the function but it turned out not to be because I tried doing this:
pawn Код:
CMD:unfreeze(playerid, params[])
{
    if (PlayerInfo[playerid][pAdmin] >= 2)
    {
        new string[128], giveplayerid;
        if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /unfreeze [playerid]");


        if(IsPlayerConnected(giveplayerid))
        {
            DeletePVar(giveplayerid, "IsFrozen");
            TogglePlayerControllable(giveplayerid, 1);
            Drag[Drag[giveplayerid][CrimPlayer]][Cop] = 0;
            Drag[giveplayerid][Crim] = 0;
            Drag[giveplayerid][CopPlayer] = INVALID_PLAYER_ID;
            Drag[Drag[giveplayerid][CopPlayer]][CrimPlayer] = INVALID_PLAYER_ID;
            KillTimer(DragTimer[Drag[giveplayerid][CrimPlayer]]);
            format(string, sizeof(string), "AdmCmd: %s was unfrozen by %s.",GetPlayerNameEx(giveplayerid),GetPlayerNameEx(playerid));
            ABroadCast(COLOR_LIGHTRED,string,2);
        }
        else
        {
            SendClientMessageEx(playerid, COLOR_WHITE, "Invalid player specified.");
        }

    }
    else
    {
        SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
    }
    return 1;
}
Instead of using a function I used the variables and still the same result. Now I believe it is a problem with the way I made the enum that is cancelling the script?
Reply
#2

Change your function to the one below, and it will tell you where it fails.
pawn Код:
DragStop(copid, crimid)
{
    SendClientMessageToAll(0x00FF00FF, "Started");
    Drag[copid][Cop] = 0;
   
    SendClientMessageToAll(0xFFFFFFFF, "1");
    Drag[crimid][Crim] = 0;
   
    SendClientMessageToAll(0xFFFFFFFF, "2");
    Drag[copid][CopPlayer] = INVALID_PLAYER_ID;
   
    SendClientMessageToAll(0xFFFFFFFF, "3");
    Drag[crimid][CrimPlayer] = INVALID_PLAYER_ID;
   
    SendClientMessageToAll(0xFFFFFFFF, "4");
    KillTimer(DragTimer[crimid]);
   
    SendClientMessageToAll(0x00FF00FF, "Finished");
}
Reply
#3

Quote:
Originally Posted by Catalyst-
Посмотреть сообщение
Change your function to the one below, and it will tell you where it fails.
pawn Код:
DragStop(copid, crimid)
{
    SendClientMessageToAll(0x00FF00FF, "Started");
    Drag[copid][Cop] = 0;
   
    SendClientMessageToAll(0xFFFFFFFF, "1");
    Drag[crimid][Crim] = 0;
   
    SendClientMessageToAll(0xFFFFFFFF, "2");
    Drag[copid][CopPlayer] = INVALID_PLAYER_ID;
   
    SendClientMessageToAll(0xFFFFFFFF, "3");
    Drag[crimid][CrimPlayer] = INVALID_PLAYER_ID;
   
    SendClientMessageToAll(0xFFFFFFFF, "4");
    KillTimer(DragTimer[crimid]);
   
    SendClientMessageToAll(0x00FF00FF, "Finished");
}
Thanks for the help but did you see the post? As I said before, it is stopping on the variables in general. If I implemented that count script you just suggested it would stop on "Started". I did it just to give it a go and it did as I believed it would. Stopped on "Started". It is something wrong with the variables I believe.
Reply
#4

Ah... after taking a closer look at it, the problem looks to be that you're using
pawn Код:
Drag[giveplayerid][CrimPlayer]
inside of an array while it equals to INVALID_PLAYER_ID.
Reply
#5

Quote:
Originally Posted by Catalyst-
Посмотреть сообщение
Ah... after taking a closer look at it, the problem looks to be that you're using
pawn Код:
Drag[giveplayerid][CrimPlayer]
inside of an array while it equals to INVALID_PLAYER_ID.
Ohhh, I understand now. Well I fixed my issue. Thank you sir.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)