what is wrong with my array :c

Have questions about CoD4 mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

Post Reply
pcbouncer
CJ Fan
CJ Fan
Posts: 114
Joined: November 27th, 2012, 10:49 pm

what is wrong with my array :c

Post by pcbouncer » May 27th, 2013, 7:20 am

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

User avatar
MasterThomy
CJ Wannabe
CJ Wannabe
Posts: 42
Joined: December 23rd, 2008, 5:14 pm

Re: what is wrong with my array :c

Post by MasterThomy » May 27th, 2013, 9:46 am

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;
}
}
Ex CoD2 mapper/modder.

pcbouncer
CJ Fan
CJ Fan
Posts: 114
Joined: November 27th, 2012, 10:49 pm

Re: what is wrong with my array :c

Post by pcbouncer » May 27th, 2013, 4:25 pm

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...

pcbouncer
CJ Fan
CJ Fan
Posts: 114
Joined: November 27th, 2012, 10:49 pm

Re: what is wrong with my array :c

Post by pcbouncer » May 27th, 2013, 5:22 pm

that explains, thank you very much. one more question, how to change color and font of text?

User avatar
Goro92
CJ Spammer!
CJ Spammer!
Posts: 605
Joined: March 7th, 2011, 5:54 pm
Location: Brescia, Italy

Re: what is wrong with my array :c

Post by Goro92 » May 28th, 2013, 3:56 pm

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

Post Reply

Who is online

Users browsing this forum: No registered users and 26 guests