AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Wont give any nades. (https://forums.alliedmods.net/showthread.php?t=184458)

Bilal Pro 05-05-2012 12:46

Wont give any nades.
 
Hello there,

I tryed to make a dodgeball game, but this set_task wont give any he nades. Why wont it?


PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <fun>
#include <hamsandwich>
#include <colorchat>
#include <fakemeta>

#define PLUGIN "Dodgeball"
#define VERSION "1.0"
#define AUTHOR "Bilal"

new const Prefix[] = "[sG]"

new dodgeball[] = "models/sgknife/v_dodgeball.mdl";
new 
dodgeball2[] = "models/sgknife/p_dodgeball.mdl";

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /menu""CmdDodgeball")
}

public 
plugin_precache()
{
    
precache_model(dodgeball)
    
precache_model(dodgeball2)
}

public 
CmdDodgeball(id)
{
    new 
menu menu_create("Game:""MenuHandler")
    
    
menu_additem(menu"Dodgeball""1")
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
menu_display(idmenu0)
}

public 
MenuHandler(idmenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
data[6], szName[64], accescallback
    menu_item_getinfo
(menuitemaccesdatacharsmax(data), szNamecharsmax(szName), callback)
    new 
key str_to_num(data)
    
    switch(
key)
    {
        case 
1CmdDodgeball2(id)
        }
    return 
PLUGIN_HANDLED
}

public 
CmdDodgeball2(id)
{
    new 
name[32], players[32], iNum
    get_user_name
(idname31)
    
get_players(playersiNum"ch")
    
    for (new 
i<iNumi++)
    {
        
strip_user_weapons(players[i])
        
give_item(players[i], "weapon_hegrenade")
        
CmdDodgeball3(players[i])
        
set_pev(players[i], pev_viewmodel2dodgeball)
        
set_pev(players[i], pev_weaponmodel2dodgeball2)
    }
    
    
ColorChat(idGREY"%s ^4%s^1 has started the day: ^4Dodgeball"Prefixname)
}

public 
CmdDodgeball3(id)
{
    
set_task(0.5"GiveBalls"100_,_"b")
}

public 
GiveBalls(id)
{
    new 
players[32], iNum
    get_players
(playersiNum"a")
    
    for (new 
i<iNumi++)
    {
        if (!
is_user_alive(players[i]))
        {
            return 
PLUGIN_HANDLED
        
}
        if (!(
get_user_weapon(players[i]) == CSW_HEGRENADE))
        {
            
give_item(players[i], "weapon_hegrenade")
        }
    }
    return 
PLUGIN_CONTINUE



claudiuhks 05-05-2012 12:52

Re: Wont give any nades.
 
PHP Code:

if( !user_has_weaponiPlayerCSW_HEGRENADE ) )
{
  
//


Don't use return in loops, use only continue and break
Please search more informations about loop statements.

<VeCo> 05-05-2012 12:56

Re: Wont give any nades.
 
Make the task in plugin_init or better use a thinking entity.

Bilal Pro 05-05-2012 13:00

Re: Wont give any nades.
 
Now i have tryed this

PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <fun>
#include <hamsandwich>
#include <colorchat>
#include <fakemeta>

#define PLUGIN "Dodgeball"
#define VERSION "1.0"
#define AUTHOR "Bilal"

new const Prefix[] = "[sG]"

new dodgeball[] = "models/sgknife/v_dodgeball.mdl";
new 
dodgeball2[] = "models/sgknife/p_dodgeball.mdl";

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /menu""CmdDodgeball")
}

public 
plugin_precache()
{
    
precache_model(dodgeball)
    
precache_model(dodgeball2)
}

public 
CmdDodgeball(id)
{
    new 
menu menu_create("Game:""MenuHandler")
    
    
menu_additem(menu"Dodgeball""1")
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
menu_display(idmenu0)
}

public 
MenuHandler(idmenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
data[6], szName[64], accescallback
    menu_item_getinfo
(menuitemaccesdatacharsmax(data), szNamecharsmax(szName), callback)
    new 
key str_to_num(data)
    
    switch(
key)
    {
        case 
1CmdDodgeball2(id)
        }
    return 
PLUGIN_HANDLED
}

public 
CmdDodgeball2(id)
{
    new 
name[32], players[32], iNum
    get_user_name
(idname31)
    
get_players(playersiNum"ch")
    
    for (new 
i<iNumi++)
    {
        
strip_user_weapons(players[i])
        
give_item(players[i], "weapon_hegrenade")
        
set_task(2.0"GiveBalls"players[i], _,_"b")
        
set_pev(players[i], pev_viewmodel2dodgeball)
        
set_pev(players[i], pev_weaponmodel2dodgeball2)
    }
    
    
ColorChat(idGREY"%s ^4%s^1 has started the day: ^4Dodgeball"Prefixname)
}

public 
GiveBalls(id)
{
    if (
is_user_alive(id))
    {
        
give_item(id"weapon_hegrenade")
    }


But it still doesnt work, wont give the he nades.

Bilal Pro 05-05-2012 13:09

Re: Wont give any nades.
 
Now i am camping with a new problem,

PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <fun>
#include <hamsandwich>
#include <colorchat>
#include <fakemeta>

#define PLUGIN "Dodgeball"
#define VERSION "1.0"
#define AUTHOR "Bilal"

new const Prefix[] = "[sG]"

new dodgeball[] = "models/sgknife/v_dodgeball.mdl";
new 
dodgeball2[] = "models/sgknife/p_dodgeball.mdl";

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event("CurWeapon""Knifemodel""b""1=1")
    
    
register_clcmd("say /menu""CmdDodgeball")
}

public 
plugin_precache()
{
    
precache_model(dodgeball)
    
precache_model(dodgeball2)
}

public 
CmdDodgeball(id)
{
    new 
menu menu_create("Game:""MenuHandler")
    
    
menu_additem(menu"Dodgeball""1")
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
menu_display(idmenu0)
}

public 
MenuHandler(idmenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
data[6], szName[64], accescallback
    menu_item_getinfo
(menuitemaccesdatacharsmax(data), szNamecharsmax(szName), callback)
    new 
key str_to_num(data)
    
    switch(
key)
    {
        case 
1CmdDodgeball2(id)
        }
    return 
PLUGIN_HANDLED
}

public 
CmdDodgeball2(id)
{
    new 
name[32], players[32], iNum
    get_user_name
(idname31)
    
get_players(playersiNum"ch")
    
    for (new 
i<iNumi++)
    {
        
strip_user_weapons(players[i])
        
give_item(players[i], "weapon_hegrenade")
        
set_task(2.0"GiveBalls"players[i], _,_"b")
        
set_pev(players[i], pev_viewmodel2dodgeball)
        
set_pev(players[i], pev_weaponmodel2dodgeball2)
    }
    
    
ColorChat(idGREY"%s ^4%s^1 has started the day: ^4Dodgeball"Prefixname)
}

public 
GiveBalls(id)
{
    if (
is_user_alive(id))
    {
        
give_item(id"weapon_hegrenade")
    }
}

public 
Knifemodel(id)
{
    if (
get_user_weapon(id) == CSW_HEGRENADE)
    {
        
set_pev(idpev_viewmodel2dodgeball)
        
set_pev(idpev_weaponmodel2dodgeball2)
    }


The first he which is given is shown as the model i wanted, but after i throw it away i get a new one ofcourse but i wont see the model of it

Bilal Pro 05-05-2012 13:13

Re: Wont give any nades.
 
Nvm, Solved. Trash this please

EpicMonkey 05-05-2012 15:18

Re: Wont give any nades.
 
threads dont get thrashed , since other members could have a use for it

Bilal Pro 05-05-2012 16:23

Re: Wont give any nades.
 
Allright then

mottzi 05-05-2012 17:40

Re: Wont give any nades.
 
btw: you could post your solution for the problem so others can learn from it.

Liverwiz 05-05-2012 18:30

Re: Wont give any nades.
 
Quote:

Originally Posted by mottzi (Post 1702859)
btw: you could post your solution for the problem so others can learn from it.

please don't. your code is always trash.


All times are GMT -4. The time now is 00:24.

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