ReturnAdminName(playerid)
{
new
string[64]
;
switch (PlayerInfo[playerid][pAdmin])
{
case 1: Create3DTextLabel("Moderator", 0xFFA500FF, 30.0, 40.0, 50.0, 40.0, 0);
case 2: Create3DTextLabel("Game Administrator", 0xFFA500FF, 30.0, 40.0, 50.0, 40.0, 0);
case 3: Create3DTextLabel("Lead Administrator", 0xFFA500FF, 30.0, 40.0, 50.0, 40.0, 0);
case 4: Create3DTextLabel("Server Manager", 0xFFA500FF, 30.0, 40.0, 50.0, 40.0, 0);
default: string = "Undefined";
}
return string;
}
CMD:aduty(playerid, params[])
{
new Text3D:LabelAdmin[MAX_PLAYERS] = {TEXT3D:INVALID_3DTEXT_ID, ...};
if(IsAdmin(playerid))
{
if(IsOnAdminDuty(playerid))
{
PlayerInfo[playerid][pAdminDuty] = 0;
SendClientMessage(playerid, COLOR_YELLOW, "You are now off duty.");
Delete3DTextLabel(LabelAdmin[playerid]);
LabelAdmin[playerid] = INVALID_3DTEXT_ID;
}
else
{
new adminName[24];
format(adminName, sizeof(adminName), "%s", ReturnAdminName(playerid));
LabelAdmin[playerid] = Create3DTextLabel(adminName, 0xFFA500FF, 30.0, 40.0, 50.0, 40.0, 0);
Attach3DTextLabelToPlayer(LabelAdmin[playerid], playerid, 0.0, 0.0, 0.7);
SendClientMessageEx(playerid, COLOR_YELLOW, "You are now on duty as a %s", ReturnAdminLevel(playerid));
PlayerInfo[playerid][pAdminDuty] = 1;
}
}
else
return SendClientMessage(playerid, COLOR_RED, "ERROR: You are not an Administrator!");
return 1;
}
ReturnAdminLevel(playerid)
{
new
string[64]
;
switch (pAdmin[playerid])
{
case 1: string= "Moderator";
case 2: string= "Game Administrator";
case 3: string= "Lead Administrator";
case 4: string= "Server Manager";
default: string= "Undefined";
}
return string;
}
CMD:aduty(playerid, params[])
{
new Float:Pos[3];
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
Create3DTextLabel(ReturnAdminLevel(playerid), 0xFFA500FF, Pos[0], Pos[1], Pos[2], 40.0, 0, 0);
return 1;
}
|
Just leave the function I gave you earlier converting the level to a string, and use it inside of your command like this, you don't even have to format because it's already returned as a string.
PHP Code:
|
|
But that would just create a 3DTextLabel from where I stand and not actually attach it above my head
|
|
But that would just create a 3DTextLabel from where I stand and not actually attach it above my head
|
#include <a_samp>
#include <zcmd>
new PlayerText3D:PlayerAdminLabel[MAX_PLAYERS];
ReturnAdminLevel(playerid)
{
new
string[64]
;
switch (pInfo[playerid][Admin])
{
case 1: string= "Moderator";
case 2: string= "Game Administrator";
case 3: string= "Lead Administrator";
case 4: string= "Server Manager";
default: string= "Undefined";
}
return string;
}
CMD:aduty(playerid, params[])
{
PlayerAdminLabel[playerid] = PlayerText3D:CreatePlayer3DTextLabel(playerid, ReturnAdminLevel(playerid), 0xFFA500FF, 0, 0, 0, 40.0);
Attach3DTextLabelToPlayer(Text3D:PlayerAdminLabel[playerid], playerid, 0.0, 0.0, 0.7);
return 1;
}
|
Oh, I misunderstood.
Here's your code: pawn Code:
|
CMD:aduty(playerid, params[])
{
if(pInfo[playerid][Admin] == 0) return SendClientMessage(playerid, -1, "You need to be admin to use this command");
PlayerAdminLabel[playerid] = CreatePlayer3DTextLabel(playerid, ReturnAdminLevel(playerid), 0xFFA500FF, 0, 0, 0, 40.0);
Attach3DTextLabelToPlayer(Text3D:PlayerAdminLabel[playerid], playerid, 0.0, 0.0, 0.7);
return 1;
}
|
pawn Code:
|
CMD:aduty(playerid, params[])
{
new id;
if(IsAdmin(playerid))
{
if(IsOnAdminDuty(playerid))
{
PlayerInfo[playerid][pAdminDuty] = 0;
SendClientMessage(playerid, COLOR_YELLOW, "You are now off duty.");
Delete3DTextLabel(Text3D:PlayerAdminLabel[playerid]);
}
else
{
PlayerAdminLabel[playerid] = PlayerText3D:CreatePlayer3DTextLabel(playerid, ReturnAdminLevel(playerid), 0xFFA500FF, 0, 0, 0, 40.0);
Attach3DTextLabelToPlayer(Text3D:PlayerAdminLabel[playerid], playerid, 0.0, 0.0, 0.7);
SendClientMessageEx(playerid, COLOR_YELLOW, "You are now on duty as a %s", ReturnAdminLevel(id));
PlayerInfo[playerid][pAdminDuty] = 1;
}
}
else
return SendClientMessage(playerid, COLOR_RED, "ERROR: You are not an Administrator!");
return 1;
}
#include <a_samp>
#include <zcmd>
#include <streamer>
new Text3D:PlayerAdminLabel[MAX_PLAYERS];
ReturnAdminLevel(playerid)
{
new
string[64]
;
switch (pInfo[playerid][Admin])
{
case 1: string= "Moderator";
case 2: string= "Game Administrator";
case 3: string= "Lead Administrator";
case 4: string= "Server Manager";
default: string= "Undefined";
}
return string;
}
CMD:aduty(playerid, params[])
{
//pInfo[playerid][Admin]++; Just for tests, you can delete it
if(IsValidDynamic3DTextLabel(PlayerAdminLabel[playerid]))
DestroyDynamic3DTextLabel(PlayerAdminLabel[playerid]);
PlayerAdminLabel[playerid] = CreateDynamic3DTextLabel(ReturnAdminLevel(playerid), 0xFFA500FF, 0.0, 0.0, 0.1, 5.0, .attachedplayer = playerid, .testlos = 1);
return 1;
}
|
Try this one, I updated it using streamer plugin, tested in-game and it's working.
pawn Code:
|
DestroyDynamic3DTextLabel(PlayerAdminLabel[playerid]);
PlayerAdminLabel[playerid] = CreateDynamic3DTextLabel(ReturnAdminLevel(playerid), 0xFFA500FF, 0.0, 0.0, 0.1, 5.0, .attachedplayer = playerid, .testlos = 1);
|
./inc/admin.inc(123) : warning 213: tag mismatch
./inc/admin.inc(127) : warning 213: tag mismatch Code:
DestroyDynamic3DTextLabel(PlayerAdminLabel[playerid]); Code:
PlayerAdminLabel[playerid] = CreateDynamic3DTextLabel(ReturnAdminLevel(playerid), 0xFFA500FF, 0.0, 0.0, 0.1, 5.0, .attachedplayer = playerid, .testlos = 1); |
#include <a_samp>
#include <zcmd>
#include <streamer>
new Text3D:PlayerAdminLabel[MAX_PLAYERS];
ReturnAdminLevel(playerid)
{
new
string[64]
;
switch (pInfo[playerid][Admin])
{
case 1: string= "Moderator";
case 2: string= "Game Administrator";
case 3: string= "Lead Administrator";
case 4: string= "Server Manager";
default: string= "Undefined";
}
return string;
}
CMD:aduty(playerid, params[])
{
//pInfo[playerid][Admin]++; Just for tests, you can delete it
if(IsValidDynamic3DTextLabel(Text3D:PlayerAdminLabel[playerid]))
DestroyDynamic3DTextLabel(PlayerAdminLabel[playerid]);
PlayerAdminLabel[playerid] = Text3D:CreateDynamic3DTextLabel(ReturnAdminLevel(playerid), 0xFFA500FF, 0.0, 0.0, 0.1, 5.0, .attachedplayer = playerid, .testlos = 1);
return 1;
}
CMD:aduty(playerid, params[])
{
PlayerAdminLabel[playerid] = PlayerText3D:CreatePlayer3DTextLabel(playerid, ReturnAdminLevel(playerid), 0xFFA500FF, 0, 0, 0, 40.0);
Attach3DTextLabelToPlayer(Text3D:PlayerAdminLabel[playerid], playerid, 0.0, 0.0, 0.7);
return 1;
}
|
are you guys ok
you're creating a __PLAYER__ text label, it will only be seen by that __PLAYER__ |
|
Uh... I don't have any warning nor errors... Are you sure you're compiling the right code? If yes try this:
pawn Code:
|
|
I am okay and I am not using it (okay before I did) (can you compile that code and tell me if you get any errors/warnings please? The author says he gets 2 warnings, I don't.
|
CMD:aduty(playerid, params[])
{
new id;
if(IsAdmin(playerid))
{
if(IsOnAdminDuty(playerid))
{
PlayerInfo[playerid][pAdminDuty] = 0;
SendClientMessage(playerid, COLOR_YELLOW, "You are now off duty.");
DestroyDynamic3DTextLabel(PlayerAdminLabel[playerid]);
}
else
{
PlayerAdminLabel[playerid] = CreateDynamic3DTextLabel(ReturnAdminLevel(playerid), 0xFFA500FF, 0.0, 0.0, 0.1, 5.0, .attachedplayer = playerid, .testlos = 1);
SendClientMessageEx(playerid, COLOR_YELLOW, "You are now on duty as a %s", ReturnAdminLevel(id));
PlayerInfo[playerid][pAdminDuty] = 1;
}
}
else
return SendClientMessage(playerid, COLOR_RED, "ERROR: You are not an Administrator!");
return 1;
}