AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Looping Help (https://forums.alliedmods.net/showthread.php?t=130704)

shuttle_wave 06-26-2010 17:18

Looping Help
 
Heres my code when i attempted to loop a players name from one funtion to another

PHP Code:

public cmdGames(id)
{
    new 
iMenu menu_create("\yLastRequest:^n\rby Nibbles/Shuttle_Wave""Games_Handler")

    
menu_additem(iMenu"\wBig Games""1"0);
    
menu_additem(iMenu"\wSmall""2"0);
    
    
menu_setprop(iMenuMPROP_EXITMEXIT_ALL);
    
menu_display(idiMenu0);
    
    new 
szName[32];
    
get_user_name(idszName31);
    
    
ChoosingG true;
    
    
TaskLoopNameChoosing(szName[id])
    
}    

public 
TaskLoopNameChoosing(szName)
{
    if(
ChoosingG)
    {
        
client_printc(0"%s !g%s!n Is Choosing a !gGame!n"PREFIXszName);
        
        
set_hudmessage(
            .
red 0,
            .
green 100,
            .
blue 255,
            .
= -1.0,
            .
0.45,
            .
holdtime 1.0,
            .
effects 1,
            .
channel = -1
            
);
            
        
show_hudmessage(0"%s Is Choosing a Game"szName);
        
        
set_task(1.0"TaskLoopNameChoosing"szName);
    }


Wat am i doing rong?


Cheers
Shuttle_Wave

shuttle_wave 06-26-2010 17:19

Re: Looping Help
 
NVM. I Found my problems. Thanks

grimvh2 06-26-2010 18:33

Re: Looping Help
 
Don't make 2 topics about the same.

shuttle_wave 06-26-2010 18:47

Re: Looping Help
 
OK. I tryed the plugin out and i got something every weird. It first shows on hud s{Shuttle_Wave} is choosing a Game when its suppose to say {Shuttle_Wave} is choosing a Game but i dont no how the s got into there. AFter 1 second it shows s is choosing game. wats the problem?>

ConnorMcLeod 06-26-2010 19:18

Re: Looping Help
 
Problem is your skill :mrgreen:

szName in the public function you directly call is taken as a string, but in the public callback it's an integer.
You are even lucky that it works almost fine the 1st time.

shuttle_wave 06-27-2010 01:05

Re: Looping Help
 
Quote:

Originally Posted by ConnorMcLeod (Post 1220862)
Problem is your skill :mrgreen:

szName in the public function you directly call is taken as a string, but in the public callback it's an integer.
You are even lucky that it works almost fine the 1st time.

Oh. Wat do i have to do to fix it?

Alucard^ 06-27-2010 01:13

Re: Looping Help
 
PHP Code:

set_task(1.0"TaskLoopNameChoosing"szName); 

szName?

You are trying to pass an string value to the task, you can't do this... you have to pass in integer (id of the player for example)... so you should change this:

PHP Code:

TaskLoopNameChoosing(szName[id]) 

To this:

PHP Code:

set_task(1.0"TaskLoopNameChoosing"id); 

And get the name inside of the task... or maybe using the other parameters in the set_task( ) but i don't know about this, i never used that.

shuttle_wave 06-27-2010 02:14

Re: Looping Help
 
Ok so far i did this but now the name doesnt show

PHP Code:

public cmdGames(id)
{
    new 
iMenu menu_create("\yLastRequest:^n\rby Nibbles/Shuttle_Wave""Games_Handler")

    
menu_additem(iMenu"\wBig Games""1"0);
    
menu_additem(iMenu"\wSmall""2"0);
    
    
menu_setprop(iMenuMPROP_EXITMEXIT_ALL);
    
menu_display(idiMenu0);
    
    new 
szName[32];
    
get_user_name(idszName31);
    
    
ChoosingG true;
    
    
set_task(1.0"TaskLoopNameChoosing"id);
    
}    

public 
TaskLoopNameChoosing(szName)
{
    if(
ChoosingG)
    {
        
client_printc(0"%s !g%s!n Is Choosing a !gGame!n"PREFIXszName);
        
        
set_hudmessage(
            .
red 0,
            .
green 100,
            .
blue 255,
            .
= -1.0,
            .
0.45,
            .
holdtime 1.0,
            .
effects 1,
            .
channel = -1
            
);
            
        
show_hudmessage(0"%s Is Choosing a Game"szName);
        
        
set_task(1.0"TaskLoopNameChoosing"id);
    }



wrecked_ 06-27-2010 02:22

Re: Looping Help
 
>.<

Code:
public cmdGames(id) {     new iMenu = menu_create("\yLastRequest:^n\rby Nibbles/Shuttle_Wave", "Games_Handler")     menu_additem(iMenu, "\wBig Games", "1", 0);     menu_additem(iMenu, "\wSmall", "2", 0);         menu_setprop(iMenu, MPROP_EXIT, MEXIT_ALL);     menu_display(id, iMenu, 0);         new szName[32];     get_user_name(id, szName, 31);         ChoosingG = true;         set_task( 1.0, "TaskLoopNameChoosing", id, _, _, "b" );     }     public TaskLoopNameChoosing(id) {     if(ChoosingG)     {         new szName[32]         get_user_name( id, szName, 31 )         client_printc(0, "%s !g%s!n Is Choosing a !gGame!n", PREFIX, szName);                 set_hudmessage(             .red = 0,             .green = 100,             .blue = 255,             .x = -1.0,             .y = 0.45,             .holdtime = 1.0,             .effects = 1,             .channel = -1             );                     show_hudmessage(0, "%s Is Choosing a Game", szName);     } }

Alucard^ 06-27-2010 06:11

Re: Looping Help
 
And remove the first:

Code:
    new szName[32];     get_user_name(id, szName, 31);


All times are GMT -4. The time now is 14:45.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.