18.02.2014, 15:49
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?
Or does this need to get added at OnPlayerDisconnect? And how?
Here's the code:
SetTimerEx("UpdatePlayerStats", 300000, 1, "i", playerid);
2nd Issue:
I want to have text labels when an administrator is onduty.. However every player (admin or regular player) has 'Onduty administrator' above his head for some reason..
Here's the code:
Does this timer automaticly stop when the player disconnects?
Or does this need to get added at OnPlayerDisconnect? And how?
Here's the code:
SetTimerEx("UpdatePlayerStats", 300000, 1, "i", playerid);
2nd Issue:
I want to have text labels when an administrator is onduty.. However every player (admin or regular player) has 'Onduty administrator' above his head for some reason..
Here's the code:
pawn Код:
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;
}