Raised This Month: $ Target: $400
 0% 

Can someone repair my code ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sibox
Member
Join Date: Apr 2009
Location: Bulgaria
Old 11-24-2010 , 14:36   Can someone repair my code ?
Reply With Quote #1

i have problem with this
Code:
public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_logevent("StartRound",2,"1=Round_Start") 
    
}

public StartRound()
{
    if(get_playersnum() < 1)
        return;
    
    new cName[32]
    new randompl = random_person()
    get_user_name(randompl, cName, 31)
    give_extra( random_person() );
    set_hudmessage(255, 0, 0, -1.0, 0.01)
    show_hudmessage(0, "%s is the Choosen One!", cName)
}




random_person()
{
new iPlayers[32], iNum
get_players( iPlayers, iNum, "a" );

return iPlayers[ random( iNum ) ];
}

give_extra( id )
{
RandomWep( id )
}


RandomWep( const id ) {
switch( random_num(1,5))
{
case 1:
{
    new deagle = give_item(id, "weapon_deagle")
    cs_set_weapon_ammo(deagle, 1)
    set_user_rendering(id,kRenderFxGlowShell,255,255,0,kRenderNormal,25); 
    set_user_maxspeed(id, 1000.0);
}
case 2:
{
    new awp = give_item(id, "weapon_awp")
    cs_set_weapon_ammo(awp, 1)
    set_user_rendering(id,kRenderFxGlowShell,255,255,0,kRenderNormal,25); 
    set_user_maxspeed(id, 1000.0);
}
case 3:
{
    new usp = give_item(id, "weapon_usp")
    cs_set_weapon_ammo(usp, 2)
    set_user_rendering(id,kRenderFxGlowShell,255,255,0,kRenderNormal,25);
    set_user_maxspeed(id, 1000.0);
}
case 4:
{
    new glock = give_item(id, "weapon_glock")
    cs_set_weapon_ammo(glock, 2)
    set_user_rendering(id,kRenderFxGlowShell,255,255,0,kRenderNormal,25);
    set_user_maxspeed(id, 1000.0);
}
case 5:
{
    set_pev( id, pev_health, 150.0);
    set_user_rendering(id,kRenderFxGlowShell,255,255,0,kRenderNormal,25);
    set_user_maxspeed(id, 1000.0);
}


}
}
set_user_rendering is not working only for the random player , it's working for all players ; set_user_maxspeed not working too and get_user_name not working too
sibox is offline
Send a message via Skype™ to sibox
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 11-24-2010 , 14:45   Re: Can someone repair my code ?
Reply With Quote #2

Quote:
Originally Posted by sibox View Post
i have problem with this
Code:
public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_logevent("StartRound",2,"1=Round_Start") 
    
}

public StartRound()
{
    if(get_playersnum() < 1)
        return;
    
    new cName[32]
    new randompl = random_person()
    get_user_name(randompl, cName, 31)
    give_extra( random_person() );
    set_hudmessage(255, 0, 0, -1.0, 0.01)
    show_hudmessage(0, "%s is the Choosen One!", cName)
}




random_person()
{
new iPlayers[32], iNum
get_players( iPlayers, iNum, "a" );

return iPlayers[ random( iNum ) ];
}

give_extra( id )
{
RandomWep( id )
}


RandomWep( const id ) {
switch( random_num(1,5))
{
case 1:
{
    new deagle = give_item(id, "weapon_deagle")
    cs_set_weapon_ammo(deagle, 1)
    set_user_rendering(id,kRenderFxGlowShell,255,255,0,kRenderNormal,25); 
    set_user_maxspeed(id, 1000.0);
}
case 2:
{
    new awp = give_item(id, "weapon_awp")
    cs_set_weapon_ammo(awp, 1)
    set_user_rendering(id,kRenderFxGlowShell,255,255,0,kRenderNormal,25); 
    set_user_maxspeed(id, 1000.0);
}
case 3:
{
    new usp = give_item(id, "weapon_usp")
    cs_set_weapon_ammo(usp, 2)
    set_user_rendering(id,kRenderFxGlowShell,255,255,0,kRenderNormal,25);
    set_user_maxspeed(id, 1000.0);
}
case 4:
{
    new glock = give_item(id, "weapon_glock")
    cs_set_weapon_ammo(glock, 2)
    set_user_rendering(id,kRenderFxGlowShell,255,255,0,kRenderNormal,25);
    set_user_maxspeed(id, 1000.0);
}
case 5:
{
    set_pev( id, pev_health, 150.0);
    set_user_rendering(id,kRenderFxGlowShell,255,255,0,kRenderNormal,25);
    set_user_maxspeed(id, 1000.0);
}


}
}
set_user_rendering is not working only for the random player , it's working for all players ; set_user_maxspeed not working too and get_user_name not working too
You're using id for player index's, when "id" isn't an index in the first place.
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
sibox
Member
Join Date: Apr 2009
Location: Bulgaria
Old 11-24-2010 , 14:52   Re: Can someone repair my code ?
Reply With Quote #3

i don't understand at all. can you mark the wrong code with red
sibox is offline
Send a message via Skype™ to sibox
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 11-24-2010 , 15:46   Re: Can someone repair my code ?
Reply With Quote #4

Quote:
Originally Posted by sibox View Post
i don't understand at all. can you mark the wrong code with red
The function:

random_person()

has no id. You can't use:

give_extra( id )

because "id" isn't the function index.
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 11-24-2010 , 16:01   Re: Can someone repair my code ?
Reply With Quote #5

Quote:
Originally Posted by GXLZPGX View Post
The function:

random_person()

has no id. You can't use:

give_extra( id )

because "id" isn't the function index.
What are you talking about? random_person() returns a random player index.
The variable 'id' is just a variable name and the name has no meaning for a variable except readability.

@sibox
Your code looks fine except for this:
Code:
    give_extra( random_person() );
That gives weapons to a different random player than what the first one is.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
sibox
Member
Join Date: Apr 2009
Location: Bulgaria
Old 11-25-2010 , 06:45   Re: Can someone repair my code ?
Reply With Quote #6

I don't understand how can i fix it because i'm new :/
sibox is offline
Send a message via Skype™ to sibox
madeitout
Member
Join Date: Jun 2008
Old 11-25-2010 , 11:40   Re: Can someone repair my code ?
Reply With Quote #7

not tested
PHP Code:
public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_logevent("StartRound"2"1=Round_Start");
    
}

public 
StartRound()
{
    if (
get_playersnum() < 1)
        return;

    new 
cName[32], randompliPlayers[32], iNumweapon;

    
get_players(iPlayersiNum"a");
    
randompl iPlayers[random(iNum)];

    switch (
random_num(15))
    {
        case 
1:
        {
            
weapon give_item(randompl"weapon_deagle");
            
cs_set_weapon_ammo(weapon1);
        }
        case 
2:
        {
            
weapon give_item(randompl"weapon_awp");
            
cs_set_weapon_ammo(weapon1);
        }
        case 
3:
        {
            
weapon give_item(randompl"weapon_usp");
            
cs_set_weapon_ammo(weapon2);
        }
        case 
4:
        {
            
weapon give_item(randompl"weapon_glock");
            
cs_set_weapon_ammo(weapon2);
        }
        case 
5:
        {
            
set_pev(randomplpev_health150.0);
        }
    }

    
set_user_rendering(randomplkRenderFxGlowShell2552550kRenderNormal25); 
    
set_user_maxspeed(randompl1000.0);

    
get_user_name(randomplcName31);

    
set_hudmessage(25500, -1.00.01);
    
show_hudmessage(0"%s is the Choosen One!"cName);

__________________
madeitout is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:22.


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