PDA

View Full Version : AdminOnDuty display at /admins


Fell
11/05/2013, 06:00 AM
Hello all. I have a quick question regarding showing OnDuty or nothing if not on duty as an admin.

Basically what I want to do is if someone does /admins and an admin is on duty it should be like this:

Name_Lastname OnDuty/ReadyToHelp

And if hes not on duty it should say OffDuty instead.

Here is the code I tried to work on, it compiles and goes through but ingame it doesnt display OffDuty or OnDuty


new adminduty[64];
if(PlayerInfo[i][pAdminDuty] == 0)
{
adminduty = "OffDuty";
}
else if(PlayerInfo[i][pAdminDuty] == 1)
{
adminduty ="OnDuty/ReadyToHelp";
}



format(string, sizeof(string), "[%s]: %s *[%s]*", atext, PlayerName(i), adminduty);
SendClientMessage(playerid, COLOR_WHITE, string);

Private200
11/05/2013, 06:08 AM
Well, you can use something like this:

stock AdminDuty(playerid)
{
new AdminDuty[32];
if(PlayerInfo[playerid][pAdminDuty] == 0) format(AdminDuty, sizeof(AdminDuty), "OffDuty");
else if(PlayerInfo[playerid][pAdminDuty] == 1) format(AdminDuty, sizeof(AdminDuty), "OnDuty/ReadyToHelp");
return AdminDuty;
}

And after writing that somewhere on your script, you go over the 'OnPlayerText' or wherever you want to use it and do this:

format(string, sizeof(string), "[%s]: %s *[%s]*", atext, PlayerName(i), AdminDuty);
SendClientMessage(playerid, COLOR_WHITE, string);

This shall be fine.

Tell me if it works or either not.

EDIT: I saw this '[%s]: %s *[%s]*, atext', you're using text before name, are you sure about that? It's going to be like "Hello server: Private200 *[OnDuty]*". Change the places to fix it like this:

format(string, sizeof(string), "[%s]: %s *[%s]*", PlayerName(i), atext, AdminDuty);
SendClientMessage(playerid, COLOR_WHITE, string);

Fell
11/05/2013, 06:16 AM
Thank you for your reply, I will test it out and come back to you :)

atext = Admin Ranks. This is for /admins only not for a chat system :- )

Private200
11/05/2013, 06:26 AM
Well, it's either same. Put the code into your '/admins' command.

I've made an problem on the script first I wrote, make this changes on it:

stock AdminDuty(playerid)
{
new AdminDuty[32];
if(PlayerInfo[playerid][pAdminDuty] == 0) format(AdminDuty, sizeof(AdminDuty), "OffDuty");
else if(PlayerInfo[playerid][pAdminDuty] == 1) format(AdminDuty, sizeof(AdminDuty), "OnDuty/ReadyToHelp");
return AdminDuty;
}

Fell
11/05/2013, 06:29 AM
Having these two errors:

C:\Infinity Gaming Roleplay Server\gamemodes\U-RP.pwn(62395) : error 029: invalid expression, assumed zero
C:\Infinity Gaming Roleplay Server\gamemodes\U-RP.pwn(62395) : error 001: expected token: ";", but found "if"

Line 62395:

else if(PlayerInfo[i][pAdminDuty] == 1) format(adminduty, sizeof(adminduty), "OnDuty/ReadyToHelp");

Private200
11/05/2013, 06:30 AM
stock AdminDuty(playerid)
{
new AdminDuty[32];
if(PlayerInfo[playerid][pAdminDuty] == 0) format(AdminDuty, sizeof(AdminDuty), "OffDuty");
else if(PlayerInfo[playerid][pAdminDuty] == 1) format(AdminDuty, sizeof(AdminDuty), "OnDuty/ReadyToHelp");
return AdminDuty;
}

Change the old stock to this one, and it shall work fine.

Fell
11/05/2013, 06:37 AM
Gave me lots of errors when using return at the bottom of the code, hmm.

Fell
11/05/2013, 07:17 AM
Using this:

new adminduty[64];
if(PlayerInfo[i][pAdminDuty] == 0)
{
adminduty = "OffDuty";
}
else if(PlayerInfo[i][pAdminDuty] == 1)
{
adminduty ="OnDuty/ReadyToHelp";
}

It shows OffDuty even though Im on duty as an admin...

Your code doesn't work.

Private200
11/05/2013, 07:23 AM
Well, try to change the 'return AdminDuty;' to 'return 1;' instead.

The code you gave wont work, try to use the one I gave you.

Fell
11/05/2013, 07:59 AM
Here is your code tho..

C:\Infinity Gaming Roleplay Server\gamemodes\U-RP.pwn(59073) : error 079: inconsistent return types (array & non-array)
C:\Infinity Gaming Roleplay Server\gamemodes\U-RP.pwn(59074) : error 079: inconsistent return types (array & non-array)
C:\Infinity Gaming Roleplay Server\gamemodes\U-RP.pwn(59075) : error 079: inconsistent return types (array & non-array)
C:\Infinity Gaming Roleplay Server\gamemodes\U-RP.pwn(59076) : error 079: inconsistent return types (array & non-array)
C:\Infinity Gaming Roleplay Server\gamemodes\U-RP.pwn(59080) : error 079: inconsistent return types (array & non-array)
C:\Infinity Gaming Roleplay Server\gamemodes\U-RP.pwn(59081) : error 079: inconsistent return types (array & non-array)
C:\Infinity Gaming Roleplay Server\gamemodes\U-RP.pwn(59082) : error 079: inconsistent return types (array & non-array)
C:\Infinity Gaming Roleplay Server\gamemodes\U-RP.pwn(59083) : error 079: inconsistent return types (array & non-array)
C:\Infinity Gaming Roleplay Server\gamemodes\U-RP.pwn(59084) : error 079: inconsistent return types (array & non-array)
C:\Infinity Gaming Roleplay Server\gamemodes\U-RP.pwn(59085) : error 079: inconsistent return types (array & non-array)
C:\Infinity Gaming Roleplay Server\gamemodes\U-RP.pwn(59086) : error 079: inconsistent return types (array & non-array)
C:\Infinity Gaming Roleplay Server\gamemodes\U-RP.pwn(59087) : error 079: inconsistent return types (array & non-array)
C:\Infinity Gaming Roleplay Server\gamemodes\U-RP.pwn(59088) : error 079: inconsistent return types (array & non-array)
C:\Infinity Gaming Roleplay Server\gamemodes\U-RP.pwn(59089) : error 079: inconsistent return types (array & non-array)
C:\Infinity Gaming Roleplay Server\gamemodes\U-RP.pwn(59090) : error 079: inconsistent return types (array & non-array)
C:\Infinity Gaming Roleplay Server\gamemodes\U-RP.pwn(59091) : error 079: inconsistent return types (array & non-array)
C:\Infinity Gaming Roleplay Server\gamemodes\U-RP.pwn(59092) : error 079: inconsistent return types (array & non-array)
C:\Infinity Gaming Roleplay Server\gamemodes\U-RP.pwn(59093) : error 079: inconsistent return types (array & non-array)
C:\Infinity Gaming Roleplay Server\gamemodes\U-RP.pwn(59094) : error 079: inconsistent return types (array & non-array)
C:\Infinity Gaming Roleplay Server\gamemodes\U-RP.pwn(59095) : error 079: inconsistent return types (array & non-array)
C:\Infinity Gaming Roleplay Server\gamemodes\U-RP.pwn(59096) : error 079: inconsistent return types (array & non-array)
C:\Infinity Gaming Roleplay Server\gamemodes\U-RP.pwn(59097) : error 079: inconsistent return types (array & non-array)
C:\Infinity Gaming Roleplay Server\gamemodes\U-RP.pwn(59099) : error 079: inconsistent return types (array & non-array)
C:\Infinity Gaming Roleplay Server\gamemodes\U-RP.pwn(59100) : error 079: inconsistent return types (array & non-array)
C:\Infinity Gaming Roleplay Server\gamemodes\U-RP.pwn(59101) : error 079: inconsistent return types (array & non-array)
C:\Infinity Gaming Roleplay Server\gamemodes\U-RP.pwn(59103) : error 079: inconsistent return types (array & non-array)

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


26 Errors.