10.06.2016, 05:36
I wrote you a new code. It should work, I haven't tested it yet. Let me know if it works.
I recommend you to download the Streamer by Incognito, you can create 3D Text labels easily. You have more options using a streamer, like changing the virtual world, interior, attach it directly to a player, vehicle, etc.
PHP код:
// Make sure if you add levels change this defines and then add the respective level name into the correspond array below.
#define MAX_ADMIN_LEVELS 6
#define MAX_VIP_LEVELS 6
// This will work better instead of switching the player level/vip everytime he spawns.
new PlayerAdminLevelTagNames[MAX_ADMIN_LEVELS][] = {"Tester", "(Co-Moderator)", "(Moderator)", "(Admin)", "(Leader)", "(Manager/CEO)"},
PlayerVIPLevelTagNames[MAX_VIP_LEVELS][] = {"(Bronze VIP 1)", "(Bronze VIP 2)", "(Silver VIP 1)", "(Silver VIP 1)", "(Gold VIP 5)", "(Premium VIP 6)"},
Text3D:Admin_PlayerLabel[MAX_PLAYERS] = {Text3D:INVALID_3DTEXT_ID, ...},
Text3D:VIP_PlayerLabel[MAX_PLAYERS]= {Text3D:INVALID_3DTEXT_ID, ...}
;
public OnPlayerSpawn(playerid)
{
// If the player level is More than 0 And Less or equal to MAX_ADMIN_LEVELS and NO labels has been created for the player then..
if( 0 < PlayerInfo[playerid][Level] <= MAX_ADMIN_LEVELS && Admin_PlayerLabel[playerid] != Text3D:INVALID_3DTEXT_ID)
{
// Create the label with the corresponding level Name from the Array / NOTE: Only players in virtual world 0 will see the label!
Admin_PlayerLabel[playerid] = Create3DTextLabel(PlayerAdminLevelTagNames[PlayerInfo[playerid][Level] - 1], lightblue, 0.0, 0.0, 0.0, 40.0, 0);
Attach3DTextLabelToPlayer(Admin_PlayerLabel[playerid], playerid, 0.0, 0.0, 0.4);
}
// Same, but using the VIP Label (MAX_VIP_LEVELS)
if( 0 < PlayerInfo[playerid][pVip] <= MAX_VIP_LEVELS && VIP_PlayerLabel[playerid] != Text3D:INVALID_3DTEXT_ID)
{
VIP_PlayerLabel[playerid] = Create3DTextLabel(PlayerVIPLevelTagNames[PlayerInfo[playerid][pVip] - 1], yellow, 0.0, 0.0, 0.0, 40.0, 0);
Attach3DTextLabelToPlayer(VIP_PlayerLabel[playerid], playerid, 0.0, 0.0, 0.8); // Changed the Z-offset. What if the player is also an Admin?
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
Delete3DTextLabel(Admin_PlayerLabel[playerid]);
Delete3DTextLabel(VIP_PlayerLabel[playerid]);
return 1;
}
PHP код:
Text3D:CreateDynamic3DTextLabel(const text[], color, Float:x, Float:y, Float:z, Float:drawdistance, attachedplayer = INVALID_PLAYER_ID, attachedvehicle = INVALID_VEHICLE_ID, testlos = 0, worldid = -1, interiorid = -1, playerid = -1, Float:streamdistance = 100.0);