26.05.2012, 00:11
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...
This is the Enum I made.
This is the function I made.
My problem is when I use them in a command. For example...
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:
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?
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];
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]);
}
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;
}
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;
}