Page 1 of 1

what is wrong with my array :c

Posted: May 27th, 2013, 7:20 am
by pcbouncer
textrigger()
{

playernames = [];
trigger = getent("fin","targetname");

while (1)
{

trigger waittill ("trigger", user );

for(i=0;i<playernames.size;i++){
iprintlnbold (playernames);
if(user.name==playernames){
return;
}
}
iprintlnbold (user.name + " has finished the pcbouncer way!");
maps\mp\_utility::add_to_array(playernames, user.name);

iprintlnbold (playernames);

}
}

as you can see i was trying to make a trigger that displayed that you finished once... it doesnt work. any help much appreciated

Re: what is wrong with my array :c

Posted: May 27th, 2013, 9:46 am
by MasterThomy
For one, that return; there will completely stop the function, so noone will be able to trigger your end trigger ever again.

Anyway there's a MUCH easier solution, you just set a variable for the player that finished, and only display your text when it's not set.

Like so:

Code: Select all

textrigger()
{
trigger = getent("fin","targetname");
while (1)
{
trigger waittill ("trigger", user );
if(!isdefined(user.finished)) iprintlnbold (user.name + " has finished the pcbouncer way!");
user.finished=true;
}
}

Re: what is wrong with my array :c

Posted: May 27th, 2013, 4:25 pm
by pcbouncer
where did you get user.finished? is that a premade boolean? and can you still explain why it doesnt work... it never adds to the array and it wont let me print out that part of the array...

Re: what is wrong with my array :c

Posted: May 27th, 2013, 5:22 pm
by pcbouncer
that explains, thank you very much. one more question, how to change color and font of text?

Re: what is wrong with my array :c

Posted: May 28th, 2013, 3:56 pm
by Goro92
pcbouncer wrote:how to change color of text?
^1 - RED
^2 - GREEN
^3 - YELLOW
^4 - BLUE
^5 - CYAN
^6 - PINK
^7 - WHITE
^0 - BLACK
pcbouncer wrote:how to change font of text?
- if you are using "iprintln/iprintlnblod" i think you can't change the font
- if you use an hud element :
ex: hud_name = NewHudElem();
change the font: hud_name.font = "objective"; hud_name.font = "default";
change the font scale: hud_name.fontscale = 1.2; hud_name.fontscale = 1.4;