Administration Labels [Up to head] -
NoDi522 - 18.12.2015
Hi!
So,I made administration labels up to player's head. Now the real problem is when I set someone's level to lets say 5, it will create a label with the text "[Vlasnik]" which means owner on English. After that,if i want to change player's admin level to 4 it will create another text label with the text "[Director]",and it won't delete previous one. It creates it over the 1st label.
I had an idea to try to do something under @OnPlayerUpdate but i didn't know how to compose it...
Thanks in advance!
Cheers,Dino!
CODE:
PHP код:
CMD:makeadmin(playerid,params[])
{
new poruka[256],poruka2[650],poruka3[650],ID,level,randomiziraj = random(99999);
if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid,-1,"{FF0000}Greska:{FFFFFF} Niste se spojili na server");
if(pUlogiran[playerid] != 1) return SendClientMessage(playerid,-1,"{FF0000}Greska:{FFFFFF} Niste ulogirani na server.");
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"{FF0000}Greska:{FFFFFF} Nemate dozvolu za tu komandu");
if(sscanf(params,"ud",ID,level)) return SendClientMessage(playerid,-1,"{FF0000}Koristenje:{FFFFFF} /makeadmin [ID/ime] [level]");
{
if(level < 0 || level > 5) return SendClientMessage(playerid,-1,"{FF0000}Greska:{FFFFFF} Dozvoljeni admin leveli za dodijelu: 0-5");
if(ID == playerid)
{
PlayerInfo[playerid][pAdminKod] = randomiziraj;
PlayerInfo[playerid][pAdministrator] = level;
SetPlayerSkin(playerid,294);
format(poruka,256,"{FF0000}[A-INFO]: %s {FFFFFF}%s je postavio sebe za administratora na levelu %d",GetPlayerAdminRank(playerid),GetName(playerid),level);
SendAdminMessage(-1,poruka);
format(poruka2,650,"{FFFFFF}Postavili ste se na administracijsku poziciju. Pozicija: %s.\nKao clan administracije prihvacate pravila napisana na nasoj forum stranici.\nCestitke na tituli od citave WG Administracije.Nadamo se da cete uspjesno ispunjvati svoju duznost.\n\n{FF0000}*{FFFFFF} Dolje navedeni kod zapisite negdje na papir ili u text dokument jer ce vam\npri svakom logiranju na server on biti potreban za ulazenje na racun:\n%d",GetPlayerAdminRank(playerid),randomiziraj);
ShowPlayerDialog(playerid,DIALOG_DEFAULT,DIALOG_STYLE_MSGBOX,"WG Administration",poruka2,"Uredu","");
printf("ADMIN: %s je postavio vlastiti admin level na %d",GetName(playerid),level);
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
format(poruka,128,"{FF0000}[%s{FF0000}]",GetPlayerAdminRank(playerid));
new Text3D:AdminLabel = Create3DTextLabel(poruka,-1,x,y,z,30.0,0,0); // <---
Attach3DTextLabelToPlayer(AdminLabel,playerid,0.0,0.0,0.3); // <---
TogglePlayerControllable(playerid,1);
new INI:UFile = INI_Open(UserPath(ID));
INI_SetTag(UFile,"Podatci");
INI_WriteInt(UFile,"pAdminKod",PlayerInfo[ID][pAdminKod]);
INI_Close(UFile);
}
else
{
PlayerInfo[ID][pAdminKod] = randomiziraj;
PlayerInfo[ID][pAdministrator] = level;
SetPlayerSkin(ID,294);
format(poruka,256,"{0080FF}WG{FFFFFF}: %s {FFFFFF}%s vas je postavio za administratora na levelu %d. Cestitamo!",GetPlayerAdminRank(playerid),GetName(playerid),level);
SendClientMessage(ID,-1,poruka);
format(poruka3,650,"{FFFFFF}Postavljeni ste na administraciju poziciju od strane vlasnika. Pozicija: %s.\nKao clan administracije prihvacate pravila napisana na nasoj forum stranici.\nCestitke na tituli od citave WG Administracije.Nadamo se da cete uspjesno ispunjvati svoju duznost.\n\n{FF0000}*{FFFFFF} Dolje navedeni kod zapisite negdje na papir ili u text dokument jer ce vam\npri svakom logiranju na server on biti potreban za ulazenje na racun:\n%d",GetPlayerAdminRank(level),randomiziraj);
ShowPlayerDialog(ID,DIALOG_DEFAULT2,DIALOG_STYLE_MSGBOX,"WG Administration",poruka3,"Uredu","");
format(poruka,256,"{0080FF}WG{FFFFFF}: Postavili ste %sa za administratora na levelu %d",GetName(ID),level);
SendClientMessage(playerid,-1,poruka);
format(poruka,256,"{FF0000}[A-INFO]: %s {FFFFFF}%s je postavio %su administratora na levelu %d",GetPlayerAdminRank(playerid),GetName(playerid),GetName(ID),level);
SendAdminMessage(-1,poruka);
printf("ADMIN: %s je postavio %s za administratora na levelu %d",GetName(playerid),GetName(ID),level);
new Float:x,Float:y,Float:z;
GetPlayerPos(ID,x,y,z);
format(poruka,128,"{FF0000}[%s{FF0000}]",GetPlayerAdminRank(ID));
new Text3D:AdminLabel = Create3DTextLabel(poruka,-1,x,y,z,30.0,0,0); // <---
Attach3DTextLabelToPlayer(AdminLabel,ID,0.0,0.0,0.3); // <---
TogglePlayerControllable(ID,1);
new INI:UFile = INI_Open(UserPath(ID));
INI_SetTag(UFile,"Podatci");
INI_WriteInt(UFile,"pAdminKod",PlayerInfo[ID][pAdminKod]);
INI_Close(UFile);
}
}
return 1;
}
Re: Administration Labels [Up to head] -
TwinkiDaBoss - 18.12.2015
Dont re-create same 3d text over and over again, just update it...
PHP код:
new
Text3D:AdminLabel[MAX_PLAYERS];
CMD:makeadmin(playerid,params[])
{
new poruka[256],poruka2[650],poruka3[650],ID,level,randomiziraj = random(99999);
if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid,-1,"{FF0000}Greska:{FFFFFF} Niste se spojili na server");
if(pUlogiran[playerid] != 1) return SendClientMessage(playerid,-1,"{FF0000}Greska:{FFFFFF} Niste ulogirani na server.");
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"{FF0000}Greska:{FFFFFF} Nemate dozvolu za tu komandu");
if(sscanf(params,"ud",ID,level)) return SendClientMessage(playerid,-1,"{FF0000}Koristenje:{FFFFFF} /makeadmin [ID/ime] [level]");
{
if(level < 0 || level > 5) return SendClientMessage(playerid,-1,"{FF0000}Greska:{FFFFFF} Dozvoljeni admin leveli za dodijelu: 0-5");
if(ID == playerid)
{
PlayerInfo[playerid][pAdminKod] = randomiziraj;
PlayerInfo[playerid][pAdministrator] = level;
SetPlayerSkin(playerid,294);
format(poruka,256,"{FF0000}[A-INFO]: %s {FFFFFF}%s je postavio sebe za administratora na levelu %d",GetPlayerAdminRank(playerid),GetName(playerid),level);
SendAdminMessage(-1,poruka);
format(poruka2,650,"{FFFFFF}Postavili ste se na administracijsku poziciju. Pozicija: %s.\nKao clan administracije prihvacate pravila napisana na nasoj forum stranici.\nCestitke na tituli od citave WG Administracije.Nadamo se da cete uspjesno ispunjvati svoju duznost.\n\n{FF0000}*{FFFFFF} Dolje navedeni kod zapisite negdje na papir ili u text dokument jer ce vam\npri svakom logiranju na server on biti potreban za ulazenje na racun:\n%d",GetPlayerAdminRank(playerid),randomiziraj);
ShowPlayerDialog(playerid,DIALOG_DEFAULT,DIALOG_STYLE_MSGBOX,"WG Administration",poruka2,"Uredu","");
printf("ADMIN: %s je postavio vlastiti admin level na %d",GetName(playerid),level);
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
format(poruka,128,"{FF0000}[%s{FF0000}]",GetPlayerAdminRank(playerid));
Update3DTextLabelText(AdminLabel[playerid],0xEEEE88FF,poruka);
TogglePlayerControllable(playerid,1);
new INI:UFile = INI_Open(UserPath(ID));
INI_SetTag(UFile,"Podatci");
INI_WriteInt(UFile,"pAdminKod",PlayerInfo[ID][pAdminKod]);
INI_Close(UFile);
}
else
{
PlayerInfo[ID][pAdminKod] = randomiziraj;
PlayerInfo[ID][pAdministrator] = level;
SetPlayerSkin(ID,294);
format(poruka,256,"{0080FF}WG{FFFFFF}: %s {FFFFFF}%s vas je postavio za administratora na levelu %d. Cestitamo!",GetPlayerAdminRank(playerid),GetName(playerid),level);
SendClientMessage(ID,-1,poruka);
format(poruka3,650,"{FFFFFF}Postavljeni ste na administraciju poziciju od strane vlasnika. Pozicija: %s.\nKao clan administracije prihvacate pravila napisana na nasoj forum stranici.\nCestitke na tituli od citave WG Administracije.Nadamo se da cete uspjesno ispunjvati svoju duznost.\n\n{FF0000}*{FFFFFF} Dolje navedeni kod zapisite negdje na papir ili u text dokument jer ce vam\npri svakom logiranju na server on biti potreban za ulazenje na racun:\n%d",GetPlayerAdminRank(level),randomiziraj);
ShowPlayerDialog(ID,DIALOG_DEFAULT2,DIALOG_STYLE_MSGBOX,"WG Administration",poruka3,"Uredu","");
format(poruka,256,"{0080FF}WG{FFFFFF}: Postavili ste %sa za administratora na levelu %d",GetName(ID),level);
SendClientMessage(playerid,-1,poruka);
format(poruka,256,"{FF0000}[A-INFO]: %s {FFFFFF}%s je postavio %su administratora na levelu %d",GetPlayerAdminRank(playerid),GetName(playerid),GetName(ID),level);
SendAdminMessage(-1,poruka);
printf("ADMIN: %s je postavio %s za administratora na levelu %d",GetName(playerid),GetName(ID),level);
new Float:x,Float:y,Float:z;
GetPlayerPos(ID,x,y,z);
format(poruka,128,"{FF0000}[%s{FF0000}]",GetPlayerAdminRank(playerid));
Update3DTextLabelText(AdminLabel[playerid],0xEEEE88FF,poruka);
TogglePlayerControllable(ID,1);
new INI:UFile = INI_Open(UserPath(ID));
INI_SetTag(UFile,"Podatci");
INI_WriteInt(UFile,"pAdminKod",PlayerInfo[ID][pAdminKod]);
INI_Close(UFile);
}
}
return 1;
}
OnPlayerLogin(playerid) { //or whatever you use when they spawn for the first time
format(poruka,128,"{FF0000}[%s{FF0000}]",GetPlayerAdminRank(ID));
AdminLabel[playerid] = Create3DTextLabel(poruka,-1,x,y,z,30.0,0,0); // <---
Attach3DTextLabelToPlayer(AdminLabel[playerid],playerid,0.0,0.0,0.3);
return true;
}
Re: Administration Labels [Up to head] -
NoDi522 - 18.12.2015
Thanks! I didn't even know that Update3DTextLabelText function exists!