SA-MP Forums Archive
Switch - 3Dtextlabels - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Switch - 3Dtextlabels (/showthread.php?tid=660293)

Pages: 1 2


Switch - 3Dtextlabels - Mo123 - 30.10.2018

Code:
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;
}
Any reason why this shouldn't work? No 3Dtextlabel pops up when I use /aduty


Re: Switch - 3Dtextlabels - ProfessorX - 30.10.2018

The coordinates of textlabel maybe.


Re: Switch - 3Dtextlabels - TheToretto - 30.10.2018

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:
ReturnAdminLevel(playerid

    new 
        
string[64
    ; 
    switch (
pAdmin[playerid]) 
    { 
        case 
1string"Moderator"
        case 
2string"Game Administrator"
        case 
3string"Lead Administrator"
        case 
4string"Server Manager"
        default: 
string"Undefined"
    } 
    return 
string
}  
CMD:aduty(playeridparams[])
{
    new 
Float:Pos[3];
    
GetPlayerPos(playeridPos[0], Pos[1], Pos[2]);
    
Create3DTextLabel(ReturnAdminLevel(playerid), 0xFFA500FFPos[0], Pos[1], Pos[2], 40.000);
    return 
1;




Re: Switch - 3Dtextlabels - Mo123 - 30.10.2018

Quote:
Originally Posted by TheToretto
View Post
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:
ReturnAdminLevel(playerid

    new 
        
string[64
    ; 
    switch (
pAdmin[playerid]) 
    { 
        case 
1string"Moderator"
        case 
2string"Game Administrator"
        case 
3string"Lead Administrator"
        case 
4string"Server Manager"
        default: 
string"Undefined"
    } 
    return 
string
}  
CMD:aduty(playeridparams[])
{
    new 
Float:Pos[3];
    
GetPlayerPos(playeridPos[0], Pos[1], Pos[2]);
    
Create3DTextLabel(ReturnAdminLevel(playerid), 0xFFA500FFPos[0], Pos[1], Pos[2], 40.000);
    return 
1;

But that would just create a 3DTextLabel from where I stand and not actually attach it above my head


Re: Switch - 3Dtextlabels - UFF - 30.10.2018

Quote:
Originally Posted by Mo123
View Post
But that would just create a 3DTextLabel from where I stand and not actually attach it above my head
You can't see your own 3d textlabel (which is attached to you) by yourself but other players can. Test it with other players and check out.


Re: Switch - 3Dtextlabels - TheToretto - 30.10.2018

Quote:
Originally Posted by Mo123
View Post
But that would just create a 3DTextLabel from where I stand and not actually attach it above my head
Oh, I misunderstood.

Here's your code:

pawn Code:
#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;
}



Re: Switch - 3Dtextlabels - KinderClans - 30.10.2018

Quote:
Originally Posted by TheToretto
View Post
Oh, I misunderstood.
Oh Lord, please don't let me be misunderstood...


Re: Switch - 3Dtextlabels - J0sh... - 30.10.2018

Quote:
Originally Posted by KinderClans
View Post
Oh Lord, please don't let me be misunderstood...
you are misunderstood because you are I am misunderstanding why you are taking the piss out of a guy trying to help sir


Re: Switch - 3Dtextlabels - TheToretto - 30.10.2018




Re: Switch - 3Dtextlabels - Mo123 - 31.10.2018

Quote:
Originally Posted by TheToretto
View Post
Oh, I misunderstood.

Here's your code:

pawn Code:
#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;
}
Literally picks up other 3DTextLabel names that have nothing to do with the admin labels. I mean, each time u go on duty through /Aduty you get an existing non admin 3dtext label that was put in for something else


Re: Switch - 3Dtextlabels - UFF - 31.10.2018

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;
}
You should check if player is an admin to use this command.


Re: Switch - 3Dtextlabels - Mo123 - 31.10.2018

Quote:
Originally Posted by UFF
View Post
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;
}
You should check if player is an admin to use this command.
What? What has that got to do with anything? I mean, I have already done that, but that's not the issue here

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;
}



Re: Switch - 3Dtextlabels - TheToretto - 31.10.2018

Try this one, I updated it using streamer plugin, tested in-game and it's working.

pawn Code:
#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;
}



Re: Switch - 3Dtextlabels - Mo123 - 31.10.2018

Quote:
Originally Posted by TheToretto
View Post
Try this one, I updated it using streamer plugin, tested in-game and it's working.

pawn Code:
#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;
}
./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);



Re: Switch - 3Dtextlabels - TheToretto - 31.10.2018

Quote:
Originally Posted by Mo123
View Post
./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);
Uh... I don't have any warning nor errors... Are you sure you're compiling the right code? If yes try this:

pawn Code:
#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;
}



Re: Switch - 3Dtextlabels - v1k1nG - 31.10.2018

PHP Code:
CMD:aduty(playeridparams[]) 

    
PlayerAdminLabel[playerid] = PlayerText3D:CreatePlayer3DTextLabel(playeridReturnAdminLevel(playerid), 0xFFA500FF00040.0); 
    
Attach3DTextLabelToPlayer(Text3D:PlayerAdminLabel[playerid], playerid0.00.00.7);
    return 
1

This will create a label everytime a player inputs this command, everyone can do it as there aren't admin level checkings, and also it isn't getting destroyed.


Re: Switch - 3Dtextlabels - J0sh... - 31.10.2018

are you guys ok
you're creating a __PLAYER__ text label, it will only be seen by that __PLAYER__


Re: Switch - 3Dtextlabels - v1k1nG - 31.10.2018

True that too,
https://sampwiki.blast.hk/wiki/CreatePlayer3DTextLabel


Re: Switch - 3Dtextlabels - TheToretto - 31.10.2018

Quote:
Originally Posted by J0sh...
View Post
are you guys ok
you're creating a __PLAYER__ text label, it will only be seen by that __PLAYER__
Quote:
Originally Posted by TheToretto
View Post
Uh... I don't have any warning nor errors... Are you sure you're compiling the right code? If yes try this:

pawn Code:
#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;
}
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.


Re: Switch - 3Dtextlabels - Mo123 - 31.10.2018

Quote:
Originally Posted by TheToretto
View Post
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.
I rather use my own

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.");
            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;
}