AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   help finalize the plugin (https://forums.alliedmods.net/showthread.php?t=189686)

Trickzz 07-09-2012 20:43

help finalize the plugin
 
Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>

#define PLUGIN "Chance"
#define VERSION "1.0"
#define AUTHOR "Trickz"

#define TAG "[Chance]"

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
}

public My_Menu(id)
{
    new i_Menu = menu_create("\Hi, want to try your luck?", "menu_handler")

    menu_additem(i_Menu, "\wAll Nades", "1", 0)
    menu_additem(i_Menu, "\wGravity", "2", 0)
    menu_additem(i_Menu, "\wSpeed", "3", 0)
    menu_additem(i_Menu, "\wMoney", "4", 0)
   
    menu_additem(i_Menu, "\wTry Chance", "6", 0)
    menu_additem(i_Menu, "\wNext Time", "7", 0)

    set_task(15.0 "menu_display")
}

public chance (id)
{
        new rand = random_num(0,100)
        if(random_num(1,2,3,4,5,6) <= 10)
              switch(rand)
    {
    case 1:
    {
        client_print(id,print_chat,"You got all the Nades")
            give_item( 0, weapon_hegrenade );
            give_item( 0, weapon_flashbang );
            give_item( 0, weapon_smokegrenade );
    }
    case 2:
    {
        client_print(id,print_chat,"Your Speed:270 (def: 240)")
            set_user_maxspeed( id, 270 );
    }
    case 3:
    {
        client_print(id,print_chat,"Your Gravity:760 (def: 800:")
            set_user_gravity( id, = 0.95 );
    }
    case 4:
    {
        client_print(id,print_chat,"You've got 10.000$")
            set_user_money( id, 1000, 1 );
    }
    case 5:
    {
        client_print(id,print_chat,"EpicFail: You die... :(")
            user_kill ( 0,[0] );
    }

    menu_destroy(menu)
    return PLUGIN_HANDLED
}

Please help finalize the plugin, deleted accidentally is now trying to recover the rest of the code

Compiling:
Quote:

//AMXXPC compile.exe
// by the AMX Mod X Dev Team


//// Chance.sma
// E:\CS [HOST]\HLDS 5408 [48]\cstrike\addons\amxmodx\scripting\Chance.sma( 28) :
error 001: expected token: ",", but found "-string-"
// E:\CS [HOST]\HLDS 5408 [48]\cstrike\addons\amxmodx\scripting\Chance.sma( 28) :
warning 215: expression has no effect
// E:\CS [HOST]\HLDS 5408 [48]\cstrike\addons\amxmodx\scripting\Chance.sma( 28) :
error 001: expected token: ";", but found ")"
// E:\CS [HOST]\HLDS 5408 [48]\cstrike\addons\amxmodx\scripting\Chance.sma( 28) :
error 029: invalid expression, assumed zero
// E:\CS [HOST]\HLDS 5408 [48]\cstrike\addons\amxmodx\scripting\Chance.sma( 28) :
fatal error 107: too many error messages on one line
//
// Compilation aborted.
// 4 Errors.
// Could not locate output file E:\CS [HOST]\HLDS 5408 [48]\cstrike\addons\amxmo
dx\scripting\compiled\Chance.amx (compile failed).
//
// Compilation Time: 0,22 sec
// ----------------------------------------

Press enter to exit ...

<VeCo> 07-10-2012 06:28

Re: help finalize the plugin
 
MyMenu function is never called, there are lots of errors.
Obviously you don't know what you are doing.

guipatinador 07-11-2012 10:48

Re: help finalize the plugin
 
PHP Code:

#define TAG "[Chance]" 

You never use it.
=========
PHP Code:

public My_Menu(id)
{
    new 
i_Menu menu_create("\Hi, want to try your luck?""menu_handler"

My_Meny and menu_handler are never called.
=========
PHP Code:

    set_task(15.0 "menu_display"

Will not work.
=========
PHP Code:

             give_item0weapon_hegrenade );
             
give_item0weapon_flashbang );
             
give_item0weapon_smokegrenade ); 

Shoud be,

PHP Code:

             give_itemid"weapon_hegrenade" );
             
give_itemid"weapon_flashbang" );
             
give_itemid"weapon_smokegrenade" ); 

=========
PHP Code:

             set_user_gravityid, = 0.95 ); 

Should be,

PHP Code:

             set_user_gravityid0.95 ); 

=========
PHP Code:

        client_print(id,print_chat,"You've got 10.000$")
        
set_user_moneyid1000); 

1 - You want to give 10000$ but you only give 1000$
2 - You need to use cs_set_user_money and include cstrike.inc in the top of the file

PHP Code:

        client_print(id,print_chat,"You've got 10.000$")
        
cs_set_user_moneyid10000); 

=========
PHP Code:

        client_print(id,print_chat,"EpicFail: You die... :(")
        
user_kill 0,[0] ); 

Should be,

PHP Code:

        client_print(id,print_chat,"EpicFail: You die... :(")
        
user_kill id); 

=========
PHP Code:

    menu_destroy(menu)
    return 
PLUGIN_HANDLED 

This should be after closing the switch { } ( and you forget to close the { } in public chance(id) )

I recommend you to visit this http://forums.alliedmods.net/showthread.php?t=172936 and this http://forums.alliedmods.net/showthread.php?t=46364

Mr.Bean 07-11-2012 11:55

Re: help finalize the plugin
 
@ guipatinador U are truely genius & most active helping member on http://forums.alliedmods.net/

& helps without any hesitation ,

Trickzz 07-12-2012 06:13

Re: help finalize the plugin
 
Thanks, guipatinador

Trickzz 07-12-2012 06:32

Re: help finalize the plugin
 
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>

#define PLUGIN "Chance"
#define VERSION "1.0"
#define AUTHOR "Trickz"

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd"say /cc","My_Menu");
}

public 
My_Menu(id)
{
    new 
i_Menu menu_create("\rHi, want to try your luck?""menu_handler")

    
menu_additem(i_Menu"\wAll Nades""1"0)
    
menu_additem(i_Menu"\wGravity""2"0)
    
menu_additem(i_Menu"\wSpeed""3"0)
    
menu_additem(i_Menu"\wMoney""4"0)
    
menu_additem(i_Menu"\wSuicide""5"0)
    
    
menu_additem(i_Menu"\wTry Chance""6"0)
    
menu_additem(i_Menu"\wNext Time""7"0)

    
menu_display(idi_Menu0);
}

public 
menu_handler(idi_Menuitem)
{
    new 
data[6], szName[64];
    new 
accesscallback;
    
menu_item_getinfo(i_Menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);
    
    new 
key str_to_num(data);
    
         new 
rand random_num(0,100
         if(
random_num(1,2,3,4,5) <= 10)
              switch(
rand
    {
    case 
1..10// 10%
    
{
        
client_print(id,print_chat,"You got all the Nades")
             
give_itemid"weapon_hegrenade" );
             
give_itemid"weapon_flashbang" );
             
give_itemid"weapon_smokegrenade" ); 
    }
    case 
11..20// 10%
    
{
        
client_print(id,print_chat,"Your Speed:270 (def: 240)")
             
set_user_gravityid0.95 );
    }
    case 
21..30// 10%
    
{
        
client_print(id,print_chat,"Your Gravity:760 (def: 800:")
             
set_user_maxspeed (id270);
    }
    case 
31..40// 10%
    
{
        
client_print(id,print_chat,"You've got 10.000$")
             
cs_set_user_moneyid10000);  
    }
    case 
41..100 // 60%
    
{
        
client_print(id,print_chat,"EpicFail: You die... :(")
             
user_kill id);  
    }

    
menu_destroy(i_Menu)
    return 
PLUGIN_HANDLED


Quote:

//AMXXPC compile.exe
// by the AMX Mod X Dev Team


//// copy.sma
// E:\CS [HOST]\HLDS 5408 [48]\cstrike\addons\amxmodx\scripting\copy.sma(13 ) : w
arning 217: loose indentation
// E:\CS [HOST]\HLDS 5408 [48]\cstrike\addons\amxmodx\scripting\copy.sma(24 ) : w
arning 217: loose indentation
// E:\CS [HOST]\HLDS 5408 [48]\cstrike\addons\amxmodx\scripting\copy.sma(26 ) : w
arning 217: loose indentation
// E:\CS [HOST]\HLDS 5408 [48]\cstrike\addons\amxmodx\scripting\copy.sma(35 ) : w
arning 217: loose indentation
// E:\CS [HOST]\HLDS 5408 [48]\cstrike\addons\amxmodx\scripting\copy.sma(36 ) : w
arning 217: loose indentation
// E:\CS [HOST]\HLDS 5408 [48]\cstrike\addons\amxmodx\scripting\copy.sma(40 ) : w
arning 217: loose indentation
// E:\CS [HOST]\HLDS 5408 [48]\cstrike\addons\amxmodx\scripting\copy.sma(41 ) : e
rror 088: number of arguments does not match definition
// E:\CS [HOST]\HLDS 5408 [48]\cstrike\addons\amxmodx\scripting\copy.sma(47 ) : w
arning 217: loose indentation
// E:\CS [HOST]\HLDS 5408 [48]\cstrike\addons\amxmodx\scripting\copy.sma(54 ) : w
arning 217: loose indentation
// E:\CS [HOST]\HLDS 5408 [48]\cstrike\addons\amxmodx\scripting\copy.sma(59 ) : w
arning 217: loose indentation
// E:\CS [HOST]\HLDS 5408 [48]\cstrike\addons\amxmodx\scripting\copy.sma(59 ) : w
arning 213: tag mismatch
// E:\CS [HOST]\HLDS 5408 [48]\cstrike\addons\amxmodx\scripting\copy.sma(64 ) : w
arning 217: loose indentation
// E:\CS [HOST]\HLDS 5408 [48]\cstrike\addons\amxmodx\scripting\copy.sma(66 -- 6
7) : error 029: invalid expression, assumed zero
// E:\CS [HOST]\HLDS 5408 [48]\cstrike\addons\amxmodx\scripting\copy.sma(69 ) : w
arning 217: loose indentation
// E:\CS [HOST]\HLDS 5408 [48]\cstrike\addons\amxmodx\scripting\copy.sma(72 ) : e
rror 002: only a single statement (or expression) can follow each "case"
// E:\CS [HOST]\HLDS 5408 [48]\cstrike\addons\amxmodx\scripting\copy.sma(72 -- 7
3) : warning 215: expression has no effect
// E:\CS [HOST]\HLDS 5408 [48]\cstrike\addons\amxmodx\scripting\copy.sma(74 ) : w
arning 204: symbol is assigned a value that is never used: "key"
//
// 3 Errors.
// Could not locate output file E:\CS [HOST]\HLDS 5408 [48]\cstrike\addons\amxmo
dx\scripting\compiled\copy.amx (compile failed).
//
// Compilation Time: 0,19 sec
// ----------------------------------------

Press enter to exit ...

guipatinador 07-12-2012 08:13

Re: help finalize the plugin
 
untested,

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>

public plugin_init()
{
    
register_plugin("Chance""1.0""Trickz")
    
    
register_clcmd"say /cc","My_Menu")
}

public 
My_Menu(id)
{
    new 
i_Menu menu_create("\rHi, want to try your luck?""menu_handler")
    
    
menu_additem(i_Menu"\wAll Nades""1"0)
    
menu_additem(i_Menu"\wGravity""2"0)
    
menu_additem(i_Menu"\wSpeed""3"0)
    
menu_additem(i_Menu"\wMoney""4"0)
    
menu_additem(i_Menu"\wSuicide""5"0)
    
menu_additem(i_Menu"\wTry Chance""6"0)
    
menu_additem(i_Menu"\wNext Time""7"0)
    
    
menu_display(idi_Menu0)
}

public 
menu_handler(idi_Menuitem)
{
    new 
data[6], szName[64]
    new 
accesscallback
    menu_item_getinfo
(i_Menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback)
    
    new 
key str_to_num(data)
    
    switch(
key)
    {
        case 
1:
        {
            if(
random_num(1100) <= 10)
            {
                
client_print(id,print_chat,"You got all the Nades")
                
give_item(id"weapon_hegrenade")
                
give_item(id"weapon_flashbang")
                
give_item(id"weapon_smokegrenade")
            }
        }
        
        case 
2:
        {
            if(
random_num(1100) <= 10)
            {
                
client_print(id,print_chat,"Your Gravity:760 (def: 800)")
                
set_user_gravity(id0.95)
            }
        }
        
        case 
3:
        {
            if(
random_num(1100) <= 10)
            {
                
client_print(id,print_chat,"Your Speed:270 (def: 240)")
                
set_user_maxspeed(id270.0)
            }
        }
        
        case 
4:
        {
            if(
random_num(1100) <= 10)
            {
                
client_print(id,print_chat,"You've got 10.000$")
                
cs_set_user_money(id100001)
            }
        }
        
        case 
5:
        {
            if(
random_num(1100) <= 60)
            {
                
client_print(id,print_chat,"EpicFail: You die... :(")
                
user_kill (id0)
            }
        }
    }
    
    
menu_destroy(i_Menu)
    return 
PLUGIN_HANDLED



Trickzz 07-12-2012 14:39

Re: help finalize the plugin
 
thanks again guipatinador!
full work

Why menu not opening?
I trying a client_cmd BINDing, and chat command.

Trickzz 07-13-2012 11:39

Re: help finalize the plugin
 
Quote:

//AMXXPC compile.exe
// by the AMX Mod X Dev Team


//// copy.sma
// E:\CS [HOST]\HLDS 5408 [48]\cstrike\addons\amxmodx\scripting\copy.sma(22 ) : w
arning 217: loose indentation
// E:\CS [HOST]\HLDS 5408 [48]\cstrike\addons\amxmodx\scripting\copy.sma(23 ) : w
arning 217: loose indentation
// E:\CS [HOST]\HLDS 5408 [48]\cstrike\addons\amxmodx\scripting\copy.sma(35 ) : e
rror 029: invalid expression, assumed zero
//
// 1 Error.
// Could not locate output file E:\CS [HOST]\HLDS 5408 [48]\cstrike\addons\amxmo
dx\scripting\compiled\copy.amx (compile failed).
//
// Compilation Time: 0,19 sec
// ----------------------------------------

Press enter to exit ...
PHP Code:

switch(key

(key) - what is it, and why it mistake for compilating

guipatinador 07-13-2012 11:44

Re: help finalize the plugin
 
Plugin works fine for me... What modifications you did?


All times are GMT -4. The time now is 15:06.

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