AlliedModders

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

Zapdos1 08-14-2009 20:42

plz help
 
1 Attachment(s)
well i tried to compile this plugin but it gives me 12 errors

One 08-14-2009 20:51

Re: plz help
 
learn coding & define ur kills

PHP Code:

#include <amxmodx>
#include <fakemeta_util>
#include <cstrike>
#include <fun>
#define PLUGIN_NAME "Team Selection"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "Zapdos1"

// default names
new const TeamT[] = "Soviets"        // Terrorists
new const TeamCT[] = "Allied"    // Counter-Terrorists

// default round end sounds
new const SoundT[] = "music/downed_intro.mp3"
new const SoundCT[] = "music/motor_intro.mp3"
new camouflagetime
// Some useful code (thx to arkshine)
enum
{
    
CS_TEAM_UNASSIGNED 0,
    
CS_TEAM_T,
    
CS_TEAM_CT,
    
CS_TEAM_SPECTATOR
}

#define OFFSET_TEAM  114 
#define cs_get_user_team(%1)     get_pdata_int( %1, OFFSET_TEAM ) 

#define OFFSET_DEATHS  444
#define cs_get_user_deaths(%1)     get_pdata_int( %1, OFFSET_DEATHS )
#define cs_set_user_deaths(%1,%2)  set_pdata_int( %1, OFFSET_DEATHS, %2 )

// Some variables
new mChooseTeam
new showMsg 0
new camouflagecost
new pcTeamTpcTeamCTpcSoundTpcSoundCTpcUseSounds

public plugin_init() {
    
register_plugin(PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR);

    
register_message(get_user_msgid("ShowMenu"), "message_show_menu");
    
register_event("ResetHUD""set_hud""be");

    
// change round end message / sounds
    
register_message(get_user_msgid("SendAudio"), "message_sendaudio");
    
register_message(get_user_msgid("TextMsg"), "message_textmsg");

    
pcTeamT register_cvar("ctn_team_t"TeamT);
    
pcTeamCT register_cvar("ctn_team_ct"TeamCT);
    
pcUseSounds register_cvar("ctn_use_sounds""1");
    
pcSoundT  register_cvar("ctn_sound_t"SoundT);
    
pcSoundCT register_cvar("ctn_sound_ct"SoundCT);
    
camouflagecost register_cvar("amx_camouflagecost","1")
    
register_clcmd("chooseteam""cmdBlock");
    
camouflagetime register_cvar("amx_camouflage_time""20.0")


    
createMenu();

    return 
PLUGIN_CONTINUE;
}

public 
plugin_precache() {
    new 
sound_t[128];
    
get_pcvar_string(pcSoundTsound_t127);

    if (
containi(sound_t".mp3") != -1)
    {
        
formatex(sound_t127"sound/%s"sound_t);
        
precache_generic(sound_t);
    } else
        
precache_sound(sound_t);

    new 
sound_ct[128];
    
get_pcvar_string(pcSoundCTsound_ct127);

    if (
containi(sound_ct".mp3") != -1)
    {
        
formatex(sound_t127"sound/%s"sound_ct);
        
precache_generic(sound_ct);
    } else
        
precache_sound(sound_ct);
}

public 
client_connect(id)
{
    
set_user_info(id"_vgui_menus""0");

    return 
PLUGIN_CONTINUE;
}

public 
set_hud(id) {
    
showMsg 0;

    
set_task(0.2"fixHUD"id);
    
set_task(0.3"fadeOut"id);

    return 
PLUGIN_CONTINUE;
}

public 
fixHUD(id) {
    
// some fixes if the HUD is destroyed
    
if (!user_has_weapon(idCSW_KNIFE))
    {
        
fm_set_user_suit(id);
        
fm_give_item(id"weapon_knife");

        switch (
cs_get_user_team(id))
        {
            case 
CS_TEAM_CT:
            {
                
Submenu(id)
                 } 
            case 
CS_TEAM_T:
            {
                                     
SubMenu1(id)  
            }
        }
    }
}
public 
SubMenu1(id)
{
    
//Note that we will be using a different menu handler
    
new menu menu_create("\rChoose your soviet""submenu_handler")

    
menu_additem(menu"\wYuri""1"0);
    
menu_additem(menu"\wTesla Trooper""2"0);
    
menu_additem(menu"\wConscript""3"0);
    
menu_additem(menu"\wCrazy Ivan""4"0);

    
menu_display(idmenu0);
 }
 public 
submenu_handler(idmenuitem)
 {
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);

        
//If they are still connected
        
if( is_user_connected(id) )
            
//Lets send them back to the top menu
            
SubMenu1(id)

        return 
PLUGIN_HANDLED;
    }

    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,5iName63callback);

    new 
key str_to_num(data);

    switch(
key)
    {
        case 
1:
        {
        
give_item(id"weapon_usp")
        
client_print(idprint_chat"You are the Yuri Commander");
        }
        case 
2:
        {
        
give_item (id"weapon_knife")
        
client_print(idprint_chat"You are now a Tesla Trooper");
        }
        case 
3:
        {
        
give_item (id"weapon_ak47")
        
client_print(idprint_chat"You are now a Conscript");
        }
        case 
4:
        {
        
give_item (id"weapon_c4")
        
client_print(idprint_chat"You are now the Crazy Ivan");
        }
    
    }

    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;
    
}
public 
Submenu(id)
{
    new 
menu menu_create("\rChoose your allied""submenu_handlere")

    
menu_additem(menu"\wTanya""1"0);
    
menu_additem(menu"\wGI""2"0);
    
menu_additem(menu"\wSpy""3"0);
    
menu_additem(menu"\wChrono Legionaire""4"0);
    
    
menu_display(idmenu0);
 }
 public 
submenu_handlere(idmenuitem)
 {
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);

        
//If they are still connected
        
if( is_user_connected(id) )
            
//Lets send them back to the top menu
            
SubMenu1(id)

        return 
PLUGIN_HANDLED;
    }

    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,5iName63callback);

    new 
key str_to_num(data);

    switch(
key)
    {
        case 
1:
        {
        
give_item (id"weapon_deagle")
        
client_print(idprint_chat"You are Tanya");
        }
        case 
2:
        {
        
give_item (id"weapon_m249")
        
client_print(idprint_chat"You are now a GI");
        }
        case 
3:
        {
        
give_camouflage(id)
        
give_item (id"weapon_ak47")
        
client_print(idprint_chat"You are now a Spy");
        }
        case 
4:
        {
        
give_item (id"weapon_mac10")
        
client_print(idprint_chat"You are now a Chrono Legionaire ");
        }
    
    }

    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;
    
}
public 
give_camouflage(id)
{
    new 
cost get_pcvar_num(camouflagecost)
    
    if(
kills >= cost && is_user_alive(id))
    {
        
set_user_frags(idkills cost)
        
camouflage[id] = true
        Timer 
get_pcvar_num(camouflagetime)
        
set_task(0.1"timer_camouflage"id)
        
ColorChat(idGREEN"^x01[AMXX] ^x04%L"id"GIVECAMOUFLAGE")
                
        if(
cs_get_user_team(id) == CS_TEAM_T)
        {
            
cs_set_user_model(idMODEL_TT[random(MODELS_TT)])
             }
         
        else if(
cs_get_user_team(id) == CS_TEAM_CT)
        {
            
cs_set_user_model(idMODEL_CT[random(MODELS_CT)])
        }
    }
       
    else if(!(
is_user_alive(id)))
    {
        
ColorChat(idGREEN"^x01[AMXX] ^x04%L"id"DEAD")
    }   
       
    else if(
randomn[id] == true)
    {
        if (
is_user_alive(id))
        {
            
camouflage[id] = true
            Timer 
get_pcvar_num(camouflagetime)
            
set_task(0.1"timer_camouflage"id)
            
ColorChat(idGREEN"^x01[AMXX] ^x04%L"id"GIVECAMOUFLAGE")
        
            if(
cs_get_user_team(id) == CS_TEAM_T)
            {
                
cs_set_user_model(idMODEL_TT[random(MODELS_CT)])
            }
            
            else if(
cs_get_user_team(id) == CS_TEAM_CT)
            {
                
cs_set_user_model(idMODEL_CT[random(MODELS_TT)])
            }
        }
    }
    
    else
    {
        
ColorChat(idRED"^x01[AMXX] ^x03%L"id"NOBUY")
    }
    return 
PLUGIN_CONTINUE
}
public 
timer_camouflage(id)
{
    --
Timer
    set_task
(1.0"timer_camouflage"id)
    
set_hudmessage(2552552550.010.306.012.0)
    
show_hudmessage(id"Camouflage: [%i]",Timer)
    
    if(!(
is_user_alive(id))) 
    { 
        
remove_task(id)
        
set_task(0.1"remove_camouflage"id)    
    }
    
    if(
Timer 1)
    {
        
remove_task(id)
        
set_hudmessage(2552552550.010.306.03.0)
        
show_hudmessage(id"Camouflage: [Over]")
        
set_task(0.1"remove_camouflage"id)
    }
}
// end of a round
public round_end_msg(params[]) {
    if (
showMsg == 1)
    {
        
client_print(0print_center"%s win!"params);
        
set_task(0.2"round_end_msg"0params128);
    }
}

public 
message_textmsg(msg_idmsg_destmsg_entity) {
    static 
message[20];
    
get_msg_arg_string(2messagesizeof message 1);

    if (
equali(message"#Soviets_Win"))
    {
        new 
params[128];
        
formatex(params127"%s"TeamT);

        
showMsg 1;
        
set_task(0.2"round_end_msg"0params128);

        return 
PLUGIN_HANDLED;
    }

    if (
equali(message"#Allieds_Win"))
    {
        new 
params[128];
        
formatex(params127"%s"TeamCT);

        
showMsg 1;
        
set_task(0.2"round_end_msg"0params128);

        return 
PLUGIN_HANDLED;
    }

    return 
PLUGIN_CONTINUE;
}


// sounds
public fadeOut()
{
    
client_cmd(0"cd fadeout");
    return 
PLUGIN_CONTINUE;
}


public 
message_sendaudio(msg_idmsg_destmsg_entity) {
    static 
message[20];
    
get_msg_arg_string(2messagesizeof message 1);

    if (
equali(message"%!MRAD_terwin"))
    {
        if (
get_pcvar_num(pcUseSounds) == 1)
        {
            new 
sound_t[128];
            
get_pcvar_string(pcSoundTsound_t127);

            if (
containi(sound_t".mp3") != -1)
                
client_cmd(0"mp3 play sound/%s"sound_t);
            else
            
                
client_cmd(0"spk %s"sound_t);
        
        }
        
        return 
PLUGIN_HANDLED;
    }

    if (
equali(message"%!MRAD_ctwin"))
    {
        if (
get_pcvar_num(pcUseSounds) == 1)
        {
            new 
sound_ct[128];
            
get_pcvar_string(pcSoundCTsound_ct127);

            if (
containi(sound_ct".mp3") != -1)
                
client_cmd(0"mp3 play sound/%s"sound_ct);
            else
                
client_cmd(0"spk %s"sound_ct);
        }
            
        return 
PLUGIN_HANDLED;
    }
    
        return 
PLUGIN_CONTINUE;
}

public 
cmdBlock(id)
{
    
menu_display(idmChooseTeam0);
    return 
PLUGIN_HANDLED;
}

// custom menu
public createMenu() {
    
mChooseTeam menu_create("Choose Team""mh_ChooseTeam");

    new 
t_name[128], ct_name[128];
    
get_pcvar_string(pcTeamTt_name127);
    
get_pcvar_string(pcTeamCTct_name127);

    
menu_additem(mChooseTeamt_name"ma_ChooseTeam"ADMIN_ALL);
    
menu_additem(mChooseTeamct_name"ma_ChooseTeam"ADMIN_ALL);
    
menu_additem(mChooseTeam"Spectator""ma_ChooseTeam"ADMIN_ALL);

    return 
PLUGIN_CONTINUE;
}

public 
message_show_menu(msgiddestid) {
    if (
get_user_team(id) || task_exists(id))
        return 
PLUGIN_CONTINUE;

    static 
team_select[] = "#Team_Select";
    static 
menu_text_code[sizeof team_select];

    
get_msg_arg_string(4menu_text_codesizeof menu_text_code 1);

    if (!
equal(menu_text_codeteam_select))
        return 
PLUGIN_CONTINUE;

    
set_task(0.1"force_team_join"id);

    return 
PLUGIN_HANDLED;
}

public 
force_team_join(id) {
    
engclient_cmd(id"jointeam""6");
    
menu_display(idmChooseTeam0);

    return 
PLUGIN_CONTINUE;
}

public 
mh_ChooseTeam(idmenuitem) {
    switch (
item)
    {
        case -
3: return PLUGIN_HANDLED;

        case 
0:
            if (
cs_get_user_team(id) == CS_TEAM_T)
                return 
PLUGIN_HANDLED;
        
        case 
1:
            if (
cs_get_user_team(id) == CS_TEAM_CT)
                return 
PLUGIN_HANDLED;

        case 
2:
            if (
cs_get_user_team(id) == CS_TEAM_SPECTATOR)
                return 
PLUGIN_HANDLED;
    }    

    if (
cs_get_user_team(id) != CS_TEAM_SPECTATOR)
    {
        
user_silentkill(id);
        
cs_set_user_deaths(idcs_get_user_deaths(id) - 1);
    }

    
cs_set_user_team(iditem 1random_num(15));

    
// restart round if there is only one player (excl. bot)
    
new Players[32], playerCount;
    
get_players(PlayersplayerCount"c");

    if (
playerCount == 1)
        
server_cmd("sv_restart 1");

    return 
PLUGIN_HANDLED;



Jon 08-14-2009 21:14

Re: plz help
 
Red Alert 2 mod or something? :D

Zapdos1 08-14-2009 21:16

Re: plz help
 
yeah xD, i want to do it

One: thanks, but it gives me 6 errors

Quote:

Error: Undefined symbol "kills" on line 248
Error: Undefined symbol "kills" on line 250
Error: Undefined symbol "camouflage" on line 251
Warning: Expression has no effect on line 251
Error: Expected token: ";", but found "]" on line 251
Error: Invalid expression, assumed zero on line 251
Error: Too many error messages on one line on line 251

Compilation aborted.
6 Errors.

off-topic: i'm searching people to do the models of the weapons xD

One 08-14-2009 21:53

Re: plz help
 
i said u have to define kills

Error: Undefined symbol "kills" on line 248

Zapdos1 08-14-2009 22:32

Re: plz help
 
Quote:

Error: Invalid expression, assumed zero on line 249
Error: Expected token: ";", but found ")" on line 249
Error: Invalid expression, assumed zero on line 249
Error: Too many error messages on one line on line 249

Compilation aborted.
4 Errors.


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

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