PDA

View Full Version : Help with /aduty and /helpme


Azzeto
10/10/2011, 07:59 AM
EDIT: I think i'v fixed it, CMD:aduty(playerid,params[]){
new string[128];
if(PlayerInfo[playerid][pAdminDuty] == 0)
format(string,sizeof(string),"%s has just went on Admin Duty",GetName(playerid));
SendClientMessageToAll(COLOR_GREEN,string);
SetPlayerHealth(playerid,500000);
SetPlayerColor(playerid,COLOR_CYAN);
Player[playerid][pAdminDuty] = 1;
}
else
{
if(PlayerInfo[playerid][pAdminDuty] == 1)
format(string,sizeof(string),"%s has just went off admin duty!");
SendClientMessageToAll(playerid,COLOR_RED,string);
Player[playerid][pAdminDuty] = 0;
}
return 1;
}
But I get four errors.. I think its because the else part.
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangw ar.pwn(707) : error 017: undefined symbol "Player"
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangw ar.pwn(707) : warning 215: expression has no effect
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangw ar.pwn(707) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangw ar.pwn(707) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangw ar.pwn(707) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.

But how would I Send a message to an Admin if hes on duty? And not to normal players

[GOD]Dragonster82
10/10/2011, 08:20 AM
SendClientMessage(playerid, YOURCOLOR, "MESSAGE"); for your question

The errors are because you didn't add another bracket at the end.

Azzeto
10/10/2011, 08:21 AM
Could you show where I didnt add the bracket? Im confused
And I know "SendClientMessage" but I need it to send to the ADMINS ONLY.

[GOD]Dragonster82
10/10/2011, 08:28 AM
Not tested, because i don't know your admin system, but this should work

for(new i = 0; i < MAX_PLAYERS; i++)
if(IsPlayerConnected(i))
{
if(PlayerInfo[playerid][pAdminLevel] >= 1)
{
SendClientMessage(i, COLOR, "YOURMESSAGE");


Btw, I don't recommend you to use your current /aduty thing, because it doesn't detects if you are a admin or not, it just puts you on duty regardless of the rank

Azzeto
10/10/2011, 08:32 AM
And what about the bracket? I get three errors now.
code

CMD:aduty(playerid,params[]){
new string[128];
if(PlayerInfo[playerid][pAdmin] > 1) return SendClientMessage(playerid,COLOR_GRAY,"You're not an admin!");
if(PlayerInfo[playerid][pAdminDuty] == 0)
format(string,sizeof(string),"%s has just went on Admin Duty",GetName(playerid));
SendClientMessageToAll(COLOR_GREEN,string);
SetPlayerHealth(playerid,500000);
SetPlayerColor(playerid,COLOR_CYAN);
PlayerInfo[playerid][pAdminDuty] = 1;
}
else
{
if(PlayerInfo[playerid][pAdminDuty] == 1)
format(string,sizeof(string),"%s has just went off admin duty!");
SendClientMessageToAll(playerid,COLOR_RED,string);
Player[playerid][pAdminDuty] = 0;
}
return 1;
}
}
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangw ar.pwn(709) : warning 209: function "cmd_aduty" should return a value
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangw ar.pwn(710) : error 010: invalid function or declaration
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangw ar.pwn(712) : error 010: invalid function or declaration
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangw ar.pwn(717) : error 010: invalid function or declaration
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


3 Errors.

[GOD]Dragonster82
10/10/2011, 08:35 AM
For the 1st error:

}
// REMOVE IT return 1;
}
return 1;
}


Can you show me the where the rest of the errors are? It would be a great help.

Azzeto
10/10/2011, 08:39 AM
Error 711: else
Error 713: if(PlayerInfo[playerid][pAdminDuty] == 1)
Error 718: return 1;

Could you like copy & paste my command the fixed way with commenting what you fixed so I can see and learn from it?

[GOD]Dragonster82
10/10/2011, 08:47 AM
Go and get msn, we'll chat there.
Its pretty hard to explain here.

Azzeto
10/10/2011, 08:52 AM
I'm on my MSN, Azzeto@live.com

GrimR
10/10/2011, 09:19 AM
Try this mate:


CMD:aduty(playerid, params[])
{
new string[128];
new uName[128];

GetPlayerName(playerid, uName, sizeof(uName));

if(PlayerInfo[playerid][pAdmin] < 1) { return SendClientMessage(playerid, COLOR_GRAY, "You're not an admin!"); }
if(PlayerInfo[playerid][pAdminDuty] == 0)
{
format(string, sizeof(string), "%s has just went on Admin Duty", uName);
SendClientMessageToAll(COLOR_GREEN, string);
SetPlayerHealth(playerid, 500000);
SetPlayerColor(playerid, COLOR_CYAN);
PlayerInfo[playerid][pAdminDuty] = 1;
}
else if (PlayerInfo[playerid][pAdminDuty] == 1)
{
format(string, sizeof(string), "%s has just went off admin duty!", uName);
SendClientMessageToAll(playerid, COLOR_RED, string);
Player[playerid][pAdminDuty] = 0;
}

return 1;
}