PDA

View Full Version : Player HUD On Crosshair



malyczolg
13th February 2013, 20:49
ENG ;
Hi
where can I find a script:
when tracking the player is showing up his nickname because he wanted me to add to this rank money etc

If the council can not Find an access this script if anyone can share it?

sryy for bad english

PL :
Czesc
gdzie moge znaleźć skrypt :
gdy namierze na gracza to pokazuje sie jego nick bo chcial bym dodac do tego rank money itp

Jezeli nie da rady znalesc tego skryptu czy moze ktos go udostepnic ?

Moczulak
13th February 2013, 23:28
[PL] -> Spróbuj tego ,jeżeli coś nie będzie działać to wróc tutaj. ;)
[ENG] -> Try this, if something does not work to go back here. ;)

Ps. If anyone from staying here sees errors, please improvement script.. :p



init()
{
thread waitforconnected();
}

waitforconnected()
{
while (true)
{
level waittill("connected", player);
player thread waitforspawn();
}
}

waitforspawn()
{
self endon("disconnect");

while (true)
{
self waittill("spawned_player");
self thread isLookingAtPlayer();
}
}

isLookingAtPlayer()
{
self endon("disconnect");

players = getentarray("player", "classname");
player = undefined;
for(i=0;i < players.size;i++)
{
if(self islookingat(players[i]))
{
player = players[i];

self.hud_looking = newClientHudElem(self);
self.hud_looking.x = 320;
self.hud_looking.y = 240;
self.hud_looking.alignX = "center";
self.hud_looking.alignY = "middle";
self.hud_looking.sort = 1;
self.hud_looking.alpha = 0;
self.hud_looking.fontScale = 1.2;
self.hud_looking setText(&"Rank: "+player.rank);

self.hud_looking fadeOverTime(0.2);
self.hud_looking.alpha = 1;
}
else
{
self.hud_looking.alpha = 0;
self.hud_looking = undefined;
}
}
}


Script show only rank ;)

IzNoGoD
13th February 2013, 23:54
settext with a non precached string... way to go...


.label and setvalue

kung foo man
14th February 2013, 02:41
Hope that would work:



init()
{
precacheString(&"Rank: ");
thread waitforconnected();
}

self.hud_looking setText(&"Rank: ");
self.hud_looking setValue(player.rank);


The performance would be better with a bullettrace(..........to forward.........)["entity"]

IzNoGoD
14th February 2013, 07:22
.label, not settext ffs.

Earliboy
14th February 2013, 09:22
You want when someone is spectating? Or if youre playing and look at the player?
Cause that script wouldnt work (in my opinion) cause it would check after respawn 1 time if u look at a player, if not it will wait for next respawn.
So you would need an while(self isLookingAt(players[i])).

I made this simple script (i know its not perfect but should work) but i dind't tested it yet.
I think it should work, it should show the player.rank in the middle of the screen if you look at a player.



init()
{
precacheString(&"^3Rank: ");
thread waitforconnected();
}

waitforconnected()
{
while (true)
{
level waittill("connected", player);
player thread waitforspawn();
}
}

waitforspawn()
{
self endon("disconnect");

self.hud_looking = newClientHudElem(self);
self.hud_looking.x = 320;
self.hud_looking.y = 240;
self.hud_looking.alignX = "center";
self.hud_looking.alignY = "middle";
self.hud_looking.sort = 1;
self.hud_looking.alpha = 0;
self.hud_looking.fontScale = 1.2;
self.hud_looking.label = &"^3Rank: ";

while (true)
{
self waittill("spawned_player");
self thread spawned();
}
}

//The following part is made by Earliboy
spawned()
{
self notify("show_rank_restart");
self endon("disconnect");
self endon("show_rank_restart");

if(!isAlive(self))
return;

while(isAlive(self))
{
//Wait 2, otherwise it may lagg the server with to much players
wait 2;

//Redefine the players (if someone new joined)
players = getEntArray("player","classname");

for(i = 0; i < players.size; i++)
{
if(!isDefined(players[i]))
continue;

if(!isAlive(players[i]))
continue;

player = players[i];

if(!self isLookingAt(player))
continue;

self.hud_looking setValue(player.rank);
self.hud_looking fadeOverTime(0.2);
self.hud_looking.alpha = .7;

while(self isLookingAt(player) && isAlive(self))
wait 2;
}
}

self.hud_looking.alpha = 0;
}

malyczolg
14th February 2013, 15:54
Earliboy
You script work but if you stop to aim the person still shows hud

pl :
Twoj skrypt dziala lecz jesli przestane celowac w osobe to nadal pokazuje hud

Jeplaa
14th February 2013, 16:29
I can't find what's wrong but try this, I wrote it a long time ago anyway should work... (it's just part of code... make it useful)


PlayersStats()
{
while(isdefined(self))
{
trace = bullettrace(self geteye()+(0,0,20),self geteye()+(0,0,20)+maps\mp\_utility::vectorscale(an glestoforward(self getplayerangles()),99999),true,self);
if(isplayer(trace["entity"]))
{
if(!isdefined(self.info))
{
self.info = newClientHudElem(self);
self.info.alignx = "center";
self.info.aligny = "center";
self.info.x = 250;
self.info.y = 250;
self.info.fontscale = 0.8;
self.info.label = &"Name: ";
self.info setplayernamestring(trace["entity"]);
self.info.alpha = 0;
self.info fadeOverTime(0.4);
self.info.alpha = 1;
}
else
self.info setplayernamestring(trace["entity"]);
}
else if(!isplayer(trace["entity"]) && isdefined(self.info))
self.info destroy();
wait 0.05;
}
}

Precache:

precacheString(&"Name: ");

malyczolg
14th February 2013, 16:42
Jeplaa
You Srcipt dont work , who can repair Earliboy SCRIPT ?

IzNoGoD
14th February 2013, 17:17
main()
{
level.rankstring = &"Rank: ";
precacheString(level.rankstring);

thread waitforconnect();
}

waitforconnect()
{
while(true)
{
level waittill("connecting", player);
player thread onconnect();
}
}

onconnect()
{
self.playerrankhud = newClientHudElem(self);
self.playerrankhud.label = level.rankstring;
self.playerrankhud.alpha = 0;
self.playerrankhud.horzAlign = "center_safearea";
self.playerrankhud.vertAlign = "center_safearea";
self.playerrankhud.alignx = "center";
self.playerrankhud.aligny = "middle";
self.playerrankhud.x = 0;
self.playerrankhud.y = 0;
self.playerrankhud.archived = false;
self.playerrankhud.foreground = false;

while(isdefined(self))
{
self waittill("spawned_player");
lookat = undefined;
while(isdefined(self) && isdefined(self.sessionstate) && self.sessionstate == "playing")
{
start = self geteye() + (0, 0, 20);
forward = anglestoforward(self getplayerangles());
end = start + maps\mp\_util::vectorScale(forward, 1000);
trace = bullettrace(start, end, true, self);
if(isdefined(trace["entity"]) && isplayer(trace["entity"]))
{
self.playerrankhud.alpha = 1;
self.playerrankhud setvalue(trace["entity"].rank);
}
else if(self.playerrankhud.alpha != 0)
{
self.playerrankhud fadeovertime(0.5);
self.playerrankhud.alpha = 0;
}
wait 0.05;
}
self.playerrankhud.alpha = 0;
}
}

I will explain this script some time..

IzNoGoD
14th February 2013, 17:17
main()
{
level.rankstring = &"Rank: ";
precacheString(level.rankstring);

thread waitforconnect();
}

waitforconnect()
{
while(true)
{
level waittill("connecting", player);
player thread onconnect();
}
}

onconnect()
{
self.playerrankhud = newClientHudElem(self);
self.playerrankhud.label = level.rankstring;
self.playerrankhud.alpha = 0;
self.playerrankhud.horzAlign = "center_safearea";
self.playerrankhud.vertAlign = "center_safearea";
self.playerrankhud.alignx = "center";
self.playerrankhud.aligny = "middle";
self.playerrankhud.x = 0;
self.playerrankhud.y = 0;
self.playerrankhud.archived = false;
self.playerrankhud.foreground = false;

while(isdefined(self))
{
self waittill("spawned_player");
lookat = undefined;
while(isdefined(self) && isdefined(self.sessionstate) && self.sessionstate == "playing")
{
start = self geteye() + (0, 0, 20);
forward = anglestoforward(self getplayerangles());
end = start + maps\mp\_util::vectorScale(forward, 1000);
trace = bullettrace(start, end, true, self);
if(isdefined(trace["entity"]) && isplayer(trace["entity"]))
{
self.playerrankhud.alpha = 1;
self.playerrankhud setvalue(trace["entity"].rank);
}
else if(self.playerrankhud.alpha != 0)
{
self.playerrankhud fadeovertime(0.5);
self.playerrankhud.alpha = 0;
}
wait 0.05;
}
self.playerrankhud.alpha = 0;
}
}

I will explain this script some time..

malyczolg
14th February 2013, 17:32
******* script compile error *******
Could not find script 'maps/mp/_util': (file 'drczolg/_cross.gsc', line 40)
end = start + maps\mp\_util::vectorScale(forward, 1000);

malyczolg
14th February 2013, 17:39
Thanks For Script IzNoGoD .

Jeplaa
14th February 2013, 17:51
Jeplaa
You Srcipt dont work , who can repair Earliboy SCRIPT ?

I have checked - it work, maybe you didn't precache, anyway solved.

malyczolg
14th February 2013, 17:57
IzNoGoD
eng:
Your script works but it shows my rank, etc instead of the player on whose tracked

pl:
twoj skrypt dziala lecz pokazuje moj rank itp zamiast gracza na ktorego namierzylem


main()
{
level.rankstring = &"RA^9NK^2:^7 ";
precacheString(level.rankstring);

thread waitforconnect();
}

waitforconnect()
{
while(true)
{
level waittill("connecting", player);
player thread onconnect();
player thread moneyhud();
}
}

onconnect()
{
self.playerrankhud = newClientHudElem(self);
self.playerrankhud.label = level.rankstring;
self.playerrankhud.alpha = 0;
self.playerrankhud.horzAlign = "center_safearea";
self.playerrankhud.vertAlign = "center_safearea";
self.playerrankhud.alignx = "center";
self.playerrankhud.aligny = "middle";
self.playerrankhud.x = 0;
self.playerrankhud.y = 0;
self.playerrankhud.archived = false;
self.playerrankhud.foreground = false;

while(isdefined(self))
{
self waittill("spawned_player");
lookat = undefined;
while(isdefined(self) && isdefined(self.sessionstate) && self.sessionstate == "playing")
{
start = self geteye() + (0, 0, 20);
forward = anglestoforward(self getplayerangles());
end = start + maps\mp\_utility::vectorScale(forward, 1000);
trace = bullettrace(start, end, true, self);
if(isdefined(trace["entity"]) && isplayer(trace["entity"]))
{
self.playerrankhud.alpha = 1;
self.playerrankhud setvalue(self.rankc);
}
else if(self.playerrankhud.alpha != 0)
{
self.playerrankhud fadeovertime(0.5);
self.playerrankhud.alpha = 0;
}
wait 0.05;
}
self.playerrankhud.alpha = 0;
}
}

malyczolg
14th February 2013, 19:24
ok i repair it
topic close plz;)

Earliboy
14th February 2013, 20:02
Could u just post the "repaired" script? So if someone else wanna use it, he can use the working version.

IzNoGoD
14th February 2013, 20:04
IzNoGoD
eng:
Your script works but it shows my rank, etc instead of the player on whose tracked

pl:
twoj skrypt dziala lecz pokazuje moj rank itp zamiast gracza na ktorego namierzylem

Should show the rank of the player you are looking at. Did you test it correctly?

Else the bullettrace() doesnt work like it should, which i find very hard to believe...