new Text3D:admintext[MAX_PLAYERS];
new Text3D:modtext[MAX_PLAYERS];
if (strcmp("/onduty", cmdtext, true, 7) == 0)
{
if (PlayerInfo[playerid][pAdmin] > 0)
{
if (AdminDuty[playerid] == 1)
{
SendClientMessage(playerid, COLOR_RED, "You are already onduty.");
}
else if (AdminDuty[playerid] == 0)
{
if (IsHidden[playerid] == 0)
{
//SendClientMessage(playerid, COLOR_LIGHTBLUE, "You are now onduty.");
AdminDuty[playerid] = 1;
new name[MAX_PLAYER_NAME+1];
new string[64+MAX_PLAYER_NAME+1];
GetPlayerName(playerid, name, sizeof(name));
GetAdminTitle(playerid);
format(string, sizeof(string), "%s %s (ID %d) has gone onduty.", AdminTitle[playerid], name, playerid);
SendClientMessageToAll(COLOR_DARKCYAN, string);
if (PlayerInfo[playerid][pAdmin] == 1 || PlayerInfo[playerid][pAdmin] == 2)
{
modtext[playerid] = Create3DTextLabel("Onduty Moderator", COLOR_LIGHTBLUE, 30.0, 40.0, 50.0, 40.0, 0);
Attach3DTextLabelToPlayer(modtext[playerid], playerid, 0.0, 0.0, 0.7);
}
else if (PlayerInfo[playerid][pAdmin] == 3 || PlayerInfo[playerid][pAdmin] == 4 || PlayerInfo[playerid][pAdmin] == 5)
{
admintext[playerid] = Create3DTextLabel("Onduty Administrator", COLOR_LIGHTBLUE, 30.0, 40.0, 50.0, 40.0, 0);
Attach3DTextLabelToPlayer(admintext[playerid], playerid, 0.0, 0.0, 0.7);
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "You cannot go onduty whilst you are hidden from the administrators list!");
}
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "Your moderator/admistrator level is not high enough to go onduty!");
}
return 1;
}
if (strcmp("/offduty", cmdtext, true, 8) == 0)
{
if (PlayerInfo[playerid][pAdmin] > 0)
{
if (AdminDuty[playerid] == 0)
{
SendClientMessage(playerid, COLOR_RED, "You are already offduty.");
}
else if (AdminDuty[playerid] == 1)
{
//SendClientMessage(playerid, COLOR_LIGHTBLUE, "You are now offduty.");
AdminDuty[playerid] = 0;
new name[MAX_PLAYER_NAME+1];
new string[64+MAX_PLAYER_NAME+1];
GetPlayerName(playerid, name, sizeof(name));
GetAdminTitle(playerid);
format(string, sizeof(string), "%s %s (ID %d) is no longer onduty.",AdminTitle[playerid], name, playerid);
SendClientMessageToAll(COLOR_DARKCYAN, string);
Delete3DTextLabel(modtext[playerid]);
Delete3DTextLabel(admintext[playerid]);
DeletePlayer3DTextLabel(playerid, PlayerText3D:admintext[playerid]);
DeletePlayer3DTextLabel(playerid, PlayerText3D:modtext[playerid]);
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "Your moderator/admistrator level is not high enough to go offduty!");
}
return 1;
}
if (PlayerInfo[playerid][pAdmin] == 1 || PlayerInfo[playerid][pAdmin] == 2 && AdminDuty[playerid] == 1)
I don't think it would be necessary for you to use a KillTimer function (as that is the function you need to kill timers) at OnPlayerDisconnect.
Also, for your 3dtextlabel, make it only show when admins are on duty. pawn Код:
|
#include <a_samp>
#include <zcmd>
new Text3D:admintext[MAX_PLAYERS];
new Text3D:modtext[MAX_PLAYERS];
new pAdmin[MAX_PLAYERS]; // admin variable
new pAduty[MAX_PLAYERS]; // aduty variable
CMD:aduty(playerid, params[])
{
if(pAdmin[playerid] > 0)
{
if(pAduty[playerid] == 0)
{
pAduty[playerid] = 1;
SendClientMessage(playerid, -1, "You have gone on admin duty!");
if(pAdmin[playerid] > 0)
{
modtext[playerid] = Create3DTextLabel("Onduty Moderator", COLOR_LIGHTBLUE, 30.0, 40.0, 50.0, 40.0, 0);
Attach3DTextLabelToPlayer(modtext[playerid], playerid, 0.0, 0.0, 0.7);
}
else if(pAdmin[playerid] > 3)
{
admintext[playerid] = Create3DTextLabel("Onduty Administrator", COLOR_LIGHTBLUE, 30.0, 40.0, 50.0, 40.0, 0);
Attach3DTextLabelToPlayer(admintext[playerid], playerid, 0.0, 0.0, 0.7);
}
}
else if(pAduty[playerid] == 1)
{
pAduty[playerid] = 0;
DeletePlayer3DTextLabel(playerid, admintext[playerid]);
DeletePlayer3DTextLabel(playerid, modtext[playerid]);
SendClientMessage(playerid, -1, "You have gone off admin duty!");
}
}
else SendClientMessage(playerid, -1, "You're not an administrator.");
return 1;
}
I have a timer that starts when the player connects which saves his stats every 5 minutes incase the server crashes,
Does this timer automaticly stop when the player disconnects? |
// OnPlayerConnect
SetPVarInt(playerid, "tUpdate", SetTimerEx("UpdatePlayerStats", 300000, 1, "i", playerid));
// OnPlayerDisconnect
KillTimer(GetPVarInt(playerid, "tUpdate"));