PDA

View Full Version : [Tutorial] Labelīs



SergiuOfficial
01-06-17, 21:32
Hello,
I decided to create an tutorial about labels.

I will start labels who just stand in a place and doenst do anything.

okay at the top of your script :

Code:
new Text3D:label[MAX_PLAYERS];

Code:
Create3DTextLabel("I'm at the coordinates:\nX, Y, Z", 0x008080FF, X, Y, Z, 40.0, 0, 0);
http://wiki.sa-mp.com/wiki/Create3DTextLabel

that's just a label with names, if you want it on a player's head or on a vehicle you need:

This is to just attach is to a player.

Code:
new Text3D:label = Create3DTextLabel("Hello, I am new here!", 0x008080FF, 30.0, 40.0, 50.0, 40.0, 0);
Attach3DTextLabelToPlayer(label, playerid, 0.0, 0.0, 0.7); // X, Y , Z
Code:
You can just make a command like
COMMAND:admintag(playerid,params[])
{
new Text3D:label = Create3DTextLabel("Hello, I am new here!", 0x008080FF, 30.0, 40.0, 50.0, 40.0, 0);
Attach3DTextLabelToPlayer(label, playerid, 0.0, 0.0, 0.7); // X, Y , Z
return 1; // just return 1;
}
if you want it attached to a vehicle you just do :

You need to add this at the top of your script :
Code:
new Text3D:vehicle3Dtext[MAX_VEHICLES],vehicle_id;

than under ongamemodeinit :
Code:
vehicle_id = CreateVehicle( 510, 0.0. 0.0, 15.0, 5, 0, 120 );
vehicle3Dtext[ vehicle_id ] = Create3DTextLabel( "Example Text", 0xFF0000AA, 0.0, 0.0, 0.0, 50.0, 0, 1 );
//Creating the Vehicle
//Attaching Text Label To Vehicle
Attach3DTextLabelToVehicle( vehicle3Dtext[ vehicle_id ] , vehicle_id, 0.0, 0.0, 2.0);
[/pawn]
and for the vehicle label you need to place this under ongamemodeexit :
Code:
Delete3DTextLabel( vehicle3Dtext[ vehicle_id ] );
return true;

Now I show it how to make a label above admin/vip's name like

Administrator NAME
Bronze VIP Name.

Add this at the top of you're script
Code:
new Text3D:label[MAX_PLAYERS];

Add this under ongamemodeinit :
Change
Code:
playerInfo[playerid][pAdminLevel])

to you're own maby get it from a kick command and you see if playervariables ... copy that and paste here.

so stock hereyouownvariable(playerid)

Code:
stock AdminLevelToName(playerid)
{
new admin[128];
switch(playerInfo[playerid][pAdminLevel])
{

case 1:
{
admin = "Junior Administrator";
}
case 2:
{
admin = "Senior Administrator";
}
case 3:
{
admin = "Head Administrator";
}
case 4:
{
admin = "Community Advisor";
}
case 5:
{
admin = "Elite Administrators";
}
case 1337:
{
admin = "Server Co-Owner";
}
case 1338:
{
admin = "Server Owner";
}
}
return admin;
}

You can also make this for VIP's.
The cases means the Admin level the player is.

And now the command.

Code:
COMMAND:admintag(playerid,params[])
{
new string[128];
format(string, sizeof(string), "%s %s \n "EMBED_WHITE" ..-rp Administrator.", AdminLevelToName(playerid), szPlayerName); // creates the string
label[playerid] = Create3DTextLabel(string, COLOR_RED, 30.0, 40.0, 50.0, 40.0, 0, 0); // create's the 3d label
Attach3DTextLabelToPlayer(label[playerid], playerid, 0.0, 0.0, 0.7); // labels attaches it.
return 1;
}
This is my first interview don't be that angry if I did something wrong.
I hope you guys learned something about strings.