Raised This Month: $51 Target: $400
 12% 

[L4D] TankSoccer


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GajoFBI
Junior Member
Join Date: Apr 2009
Old 07-12-2009 , 11:09   [L4D] TankSoccer
Reply With Quote #1

Hi,

I'm trying to make an plugin where players can play soccer/football as a Tank on Versus.
(Based on Marquis Posa idea: http://www.youtube.com/watch?v=G5BWwaZI1-c#t=5m38s)

This is my first SourcePawn plugin and I'm trying to integrate it on SourceMod Admin Menu.

It compiles without any error, but I can't get it to work... (Nothing Happens)

PHP Code:
#pragma semicolon 1
#include <sourcemod>

#undef REQUIRE_PLUGIN
#include <adminmenu>

#define PLUGIN_VERSION "1.0"

new Handle:hTopMenu INVALID_HANDLE;
new 
TopMenuObject:menuTankSoccer INVALID_TOPMENUOBJECT;
new 
TopMenuObject:menuTankSoccerOFF INVALID_TOPMENUOBJECT;
new 
TopMenuObject:menuTankSoccerBALL INVALID_TOPMENUOBJECT;

public 
Plugin:myinfo =
{
    
name "TankSoccer",
    
author "GajoFBI (Based on Marquis Posa Idea)",
    
description "Play Soccer with Tanks",
    
version PLUGIN_VERSION,
    
url "http://www.sourcemod.net/"
};

public 
OnPluginStart()
{
    
decl String:ModName[50];
    
GetGameFolderName(ModNamesizeof(ModName));

    if (!
StrEqual(ModName"left4dead"false))
    {
        
SetFailState("This is a Left 4 Dead plugin.");
    }

    
CreateConVar("sm_tanksoccer_version"PLUGIN_VERSION"TankSoccer Version"FCVAR_PLUGIN FCVAR_SPONLY FCVAR_REPLICATED FCVAR_NOTIFY FCVAR_DONTRECORD);

    
RegConsoleCmd("sm_tspawn"Command_TSpawn);

    
RegAdminCmd("sm_tanksoccer"Command_TankSoccerADMFLAG_CHEATS"Enable TankSoccer.");

    
RegAdminCmd("sm_tanksocceroff"Command_TankSoccerOFFADMFLAG_CHEATS"Disable TankSoccer.");

    
RegAdminCmd("sm_tanksoccerball"Command_TankSoccerBALLADMFLAG_CHEATS"Spawn Atlas Ball.");

    new 
Handle:topmenu;
    if (
LibraryExists("adminmenu") && ((topmenu GetAdminTopMenu()) != INVALID_HANDLE))
    {
        
OnAdminMenuReady(topmenu);
    }
}

public 
AdminMenuHandler(Handle:topmenuTopMenuAction:actionTopMenuObject:object_idparamString:buffer[], maxlength)
{
    if (
action == TopMenuAction_DisplayTitle)
    {
        
Format(buffermaxlength"TankSoccer:"param);
    }
    else if (
action == TopMenuAction_DisplayOption)
    {
        
Format(buffermaxlength"TankSoccer"param);
    }
}

public 
TankSoccerMenuHandler(Handle:topmenuTopMenuAction:actionTopMenuObject:object_idparamString:buffer[], maxlength)
{
    if (
action == TopMenuAction_DisplayOption)
    {
        if (
object_id == menuTankSoccer)
        {
            
Format(buffermaxlength"Enable TankSoccer"param);
        }
        else if (
object_id == menuTankSoccerOFF)
        {
            
Format(buffermaxlength"Disabe TankSoccer"param);
        }
        else if (
object_id == menuTankSoccerBALL)
        {
            
Format(buffermaxlength"Spawn Atlas Ball"param);
        }
    }
    else if (
action == TopMenuAction_SelectOption)
    {
        if (
object_id == menuTankSoccer)
        {
            
DisplaySoccerTankMenu(param);
        }
        else if (
object_id == menuTankSoccerOFF)
        {
            
DisplaySoccerTankOFFMenu(param);
        }
        else if (
object_id == menuTankSoccerBALL)
        {
            
DisplaySoccerTankOFFMenu(param);
        }
    }
}

public 
Action:Command_TSpawn(clientargs)
{
    
PrintToConsole(client"z_spawn tank");
    
PrintToConsole(client"give health");
    return 
Plugin_Handled;
}

public 
Action:Command_TankSoccer(clientargs)
{
    if (
client == 0)
    {
        
ReplyToCommand(client"[SM] %t""Command is in-game only.");
        return 
Plugin_Handled;
    }

    if (
args == 0)
    {
        
DisplaySoccerTankMenu(client);
    }
    
PrintToChatAll("This server is now running TankSoccer. To Spawn as a tank, Type: !tspawn .");
    return 
Plugin_Handled;
}

public 
Action:Command_TankSoccerOFF(clientargs)
{
    if (
client == 0)
    {
        
ReplyToCommand(client"[SM] %t""Command is in-game only.");
        return 
Plugin_Handled;
    }

    if (
args == 0)
    {
        
DisplaySoccerTankOFFMenu(client);
    }
    
PrintToChat(client"TankSoccer has been Disabled Sucessfully.");
    return 
Plugin_Handled;
}

public 
Action:Command_TankSoccerBALL(clientargs)
{
    if (
client == 0)
    {
        
ReplyToCommand(client"[SM] %t""Command is in-game only.");
        return 
Plugin_Handled;
    }

    if (
args == 0)
    {
        
DisplaySoccerTankBALLMenu(client);
    }
    
PrintToChat(client"An Atlas Ball was Spawned.");
    return 
Plugin_Handled;
}

DisplaySoccerTankMenu(client)
{
    if (!
IsClientInGame(client) || IsClientInKickQueue(client))
        return;

    
PrintToConsole(client"sm_cvar mp_gamemode versus");
    
PrintToConsole(client"sm_cvar sb_all_bot_team 1");
    
PrintToConsole(client"sm_cvar z_frustration_lifetime -1");
    
PrintToConsole(client"sm_cvar z_common_limit 0");
    
PrintToConsole(client"sm_cvar sb_stop 1");
    
PrintToConsole(client"sm_cvar z_tank_health 50000");
}

DisplaySoccerTankOFFMenu(client)
{
    if (!
IsClientInGame(client) || IsClientInKickQueue(client))
        return;

    
ServerCommand("exec server.cfg");
}

DisplaySoccerTankBALLMenu(client)
{
    if (!
IsClientInGame(client) || IsClientInKickQueue(client))
        return;

    
PrintToConsole(client"prop_physics_create props_unique\airport\atlas_break_ball.mdl");
}

public 
OnLibraryRemoved(const String:name[])
{
    if (
StrEqual(name"adminmenu"))
    {
        
hTopMenu INVALID_HANDLE;
    }
}

public 
OnAdminMenuReady(Handle:topmenu)
{
    if (
topmenu == hTopMenu)
    {
        return;
    }
    
hTopMenu topmenu;

    new 
TopMenuObject:objTankSoccerMenu FindTopMenuCategory(hTopMenu"Left4Dead");
    if (
objTankSoccerMenu == INVALID_TOPMENUOBJECT)
        
objTankSoccerMenu AddToTopMenu(hTopMenu"Left4Dead"TopMenuObject_CategoryAdminMenuHandlerINVALID_TOPMENUOBJECT);

    
menuTankSoccer AddToTopMenu(hTopMenu"L4D_TankSoccer_Item"TopMenuObject_ItemTankSoccerMenuHandlerobjTankSoccerMenu"sm_tanksoccer"ADMFLAG_CHEATS);

    
menuTankSoccerOFF AddToTopMenu(hTopMenu"L4D_TankSoccer_OFF_Item"TopMenuObject_ItemTankSoccerMenuHandlerobjTankSoccerMenu"sm_tanksocceroff"ADMFLAG_CHEATS);

    
menuTankSoccerBALL AddToTopMenu(hTopMenu"L4D_TankSoccer_BALL_Item"TopMenuObject_ItemTankSoccerMenuHandlerobjTankSoccerMenu"sm_tanksoccerball"ADMFLAG_CHEATS);

Can you guys please fix this or make a new one?


My Idea:

To enable TankSoccer Mod, Type: !tanksoccer
Example:
PHP Code:
PrintToConsole(client"sm_cvar mp_gamemode versus");
PrintToConsole(client"sm_cvar sb_all_bot_team 1");
PrintToConsole(client"sm_cvar z_frustration_lifetime -1");
PrintToConsole(client"sm_cvar z_common_limit 0");
PrintToConsole(client"sm_cvar sb_stop 1");
PrintToConsole(client"sm_cvar z_tank_health 50000"); 
To disable TankSoccer Mod, Type: !tanksocceroff
Example:
PHP Code:
ServerCommand("exec server.cfg"
To Spawn an Atlas Ball, Type: !tanksoccerball
Example:
PHP Code:
PrintToConsole(client"prop_physics_create props_unique\airport\atlas_break_ball.mdl"); 
To Spawn as a Tank, Type: !tspawn
Example:
PHP Code:
PrintToConsole(client"z_spawn tank");
PrintToConsole(client"give health"); 
Sorry if this is too confusing.



Thanks in advance!

Last edited by GajoFBI; 07-12-2009 at 13:54.
GajoFBI is offline
GajoFBI
Junior Member
Join Date: Apr 2009
Old 07-13-2009 , 19:30   Re: [L4D] TankSoccer
Reply With Quote #2

Someone? Plz.
GajoFBI is offline
Thraka
AlliedModders Donor
Join Date: Aug 2005
Old 07-14-2009 , 11:44   Re: [L4D] TankSoccer
Reply With Quote #3

PrintToConsole just sends a message to the client, a text message, and displays that in their console. If you want to execute commands on the server, you should use the ServerCommand method insteadl.
Thraka is offline
Reply



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 04:11.


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