AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   CS:S Source Plugin Request. (https://forums.alliedmods.net/showthread.php?t=202637)

RzGaming 12-08-2012 15:26

CS:S Source Plugin Request.
 
Hello i am requesting a Button Plugin for Counterstrike Source I can pay for it np.

What must button do?

Admins can only see what people spam on Button. its for Zombie escape.

what it must do?

1) [Buttonname] (STEAMID) Playersname : Whats the Buttons name With colors.
that is what it must do.

RzGaming 12-08-2012 17:30

Re: CS:S Source Plugin Request.
 
here is the one i have but this doenst work on all ze maps wit buttons #pragma semicolon 1

#include <sourcemod>
#include <sdktools>
#include <cstrike>


#define VERSION "1.0"

public Plugin:myinfo =
{
name = "ZK Button Spam Preventer",
author = "I3D Nightshadow",
description = "Logs button presses to chat. Original author Silence, editted for ZK by i3D Nightshadow",
version = VERSION,
url = "forum.i3d.net"
};

public OnMapStart()
{
CreateTimer( 1.0, Hook_Buttons );
}

public Action:Hook_Buttons( Handle:Timer )
{
HookEntityOutput( "func_button" , "OnPressed", ButtonPressed );
}

public ButtonPressed( const String:Output[], Caller, Activator, Float:Delay )
{
if( Activator > 0 && Activator < MaxClients && IsClientConnected(Activator) && IsClientInGame(Activator))
{
decl String:steam[32];
decl String:entity[64];
GetClientAuthString(Activator, steam, sizeof(steam));
GetEntPropString(Caller, Prop_Data, "m_iName", entity, sizeof(entity));
for (new i = 1; i <= MaxClients; i++)
{
if( IsClientInGame(i) )
{
if( CheckCommandAccess(i, "sm_chat", ADMFLAG_CHAT) )
{

PrintToChat(i, "\x03[ZK-Button]\x01 %N(%s) pressed button: %s", Activator, steam, entity );
}
}
}
}
}

public OnMapEnd()
{
UnhookEntityOutput( "func_button" , "OnPressed", ButtonPressed );

nikooo777 12-08-2012 17:53

Re: CS:S Source Plugin Request.
 
credits thanks
Code:


/* Plugin Template generated by Pawn Studio */
//THIS IS THE FIXED VERSION!!
#include <sourcemod>
#include <sdktools>
#include <cstrike>
new index =-1;
new index2 = -1;
new String:map[64];
public Plugin:myinfo =
{
        name = "4way doors hack",
        author = "Niko with special thanks to Bacardi",
        description = "informs the admins when a door is closed and who did it",
        version = "3.4",
        url = "http://forum.elite-hunterz.info"
}

public OnPluginStart()
{
        GetCurrentMap(map,sizeof(map))
        if (!strcmp(map,"zm_4way_tunnel_v2",false)) //wrong lol
        {
                HookEvent("round_start", round_start);
                RegConsoleCmd("sm_open",Command_Doors);
                HookEntityOutput( "func_button", "OnPressed", func_button);
                LogError("pluginload, map: %s",map);
        }
}

public round_start(Handle:event, const String:name[], bool:dontBroadcast)
{
       
        LogError("roundstart, map: %s",map);
        new ent = -1, String:clsname[30];
        while((ent = FindEntityByClassname(ent, "func_button")) != -1)
        {
                GetEntPropString(ent, Prop_Data, "m_iName", clsname, sizeof(clsname));
                if(StrContains(clsname, "Shutter_") == 0)
                {
                        /** These buttons in zm_4way_tunnel_v2 map
                        Shutter_left01_switch_close
                        Shutter_left01_switch_open
                        Shutter_right01_switch_close
                        Shutter_right01_switch_open
                        */
                        //LogError("changing prop data on map: %s",map);
                        SetEntProp(ent, Prop_Data, "m_spawnflags", GetEntProp(ent, Prop_Data, "m_spawnflags")|512); // Add spawnflag 512 "Damage Activates"
                        if (strcmp(clsname,"Shutter_left01_switch_open") == 0)
                        {
                                index = ent;
                        }
                        else if (strcmp(clsname,"Shutter_right01_switch_open") == 0)
                        {
                                index2 = ent;
                        }
                }
        }
        //LogError("roundstart actions ended");
}


public func_button(const String:output[], caller, activator, Float:delay)
{
        if(activator > 0 && activator <= MaxClients) // Is valid client index
        {
                new String:entity[512];
                new String:name[MAX_NAME_LENGTH];
                new String:steamid[32];
                new maxplayers = GetMaxClients();
                GetEntPropString(caller, Prop_Data, "m_iName", entity, sizeof(entity));
                //PrintToChatAll("%i",caller);
                GetClientName(activator,name,sizeof(name));
                GetClientAuthString(activator,steamid,sizeof(steamid));
                if(strcmp(entity, "Shutter_left01_switch_close") == 0)
                {
                        for (new x = 1; x <= maxplayers; x++)
                        {
                                if (!IsClientInGame(x))
                                        continue;
                                new AdminId:admin_id = GetUserAdmin(x);
                                if (admin_id != INVALID_ADMIN_ID && (GetUserFlagBits(x) & ADMFLAG_CUSTOM4))
                                {         
                                        PrintToChat(x,"The left door was closed by %s - %s", name, steamid);
                                }
                        }
                }
                else if (strcmp(entity, "Shutter_right01_switch_close") == 0)
                {
                        for (new x = 1; x <= maxplayers; x++)
                        {
                                if (!IsClientInGame(x))
                                        continue;
                                new AdminId:admin_id = GetUserAdmin(x);
                                if (admin_id != INVALID_ADMIN_ID && (GetUserFlagBits(x) & ADMFLAG_CUSTOM4))
                                {         
                                        PrintToChat(x,"The right door was closed by %s - %s", name, steamid);
                                }
                        }
                }
        }
        LogError("button press on map: %s",map);
}

public Action:Command_Doors(client,args)
{
        LogError("command doors executed on map: %s",map);
        new AdminId:admin_id = GetUserAdmin(client);
        if (IsClientInGame(client) && (admin_id != INVALID_ADMIN_ID) && (GetUserFlagBits(client) & ADMFLAG_CUSTOM4))
        {
                if(AcceptEntityInput(index,"Press",-1,-1,0) == false){
                        PrintToChatAll("there was an error opening the left door");
                        LogError("error opening left door, map: %s",map);
                }
                if(AcceptEntityInput(index2,"Press",-1,-1,0) == false){
                        PrintToChatAll("there was an error opening the right door");
                        LogError("error opening left door, map: %s",map);
                }
                else
                ReplyToCommand(client,"Doors are now open");
        }
        else
        {
                ReplyToCommand(client,"Sorry You're Not Authorized to use this command");
        }
        return Plugin_Handled;
}

as i said work on this, it has everything you need

RzGaming 12-08-2012 18:04

Re: CS:S Source Plugin Request.
 
thx i try that see if its work

nikooo777 12-08-2012 18:23

Re: CS:S Source Plugin Request.
 
this works only on the map 4way IF the plugin is loaded on 4way. (change some code to make it load everytime)
also it will print out the name of the door only if it matches the names i hardcoded, remove that and it will print out something for every button pressed.

but I gave you better source before to start with. this above only shows you how i did mine (which i changed already anyway)

this one will attemp to fix the buttons on every map it loads (if they don't have the right flags) but take care that some maps use weird ways of making buttons like func_doors instead of func_button or whatever else. so you may need to decompile the map to see how the "button" actually works.
it could be hard to make it work for every map. if you also want to output a custom name for each button, then you have to compare the button name to find a match and output whatever you want (see last quote)
Code:

#include <sourcemod>
#include <sdktools>
#include <cstrike>

public Plugin:myinfo =
{
        name = "output button entity names",
        author = "Niko",
        description = "Generates an output when a button is shot or pressed",
        version = "1.0",
        url = "forum.Elite-HunterZ.info"
}


public OnPluginStart()
{
        HookEntityOutput( "func_button", "OnPressed", Event_Impact)
        HookEntityOutput( "func_button", "OnDamaged", Event_Impact)
        HookEvent("round_start", round_start);
}
public round_start(Handle:event, const String:name[], bool:dontBroadcast)
{
        new ent = -1, String:clsname[30];
        while((ent = FindEntityByClassname(ent, "func_button")) != -1)
        {
                GetEntPropString(ent, Prop_Data, "m_iName", clsname, sizeof(clsname));
                SetEntProp(ent, Prop_Data, "m_spawnflags", GetEntProp(ent, Prop_Data, "m_spawnflags")|512); // Add spawnflag 512 "Damage Activates"
        }
}
public Event_Impact(const String:output[], caller, attacker, Float:Any) /*what is "Float:Any" exactly? what does it do?*/
{
        decl String:user[MAX_NAME_LENGTH];
        decl String:userid[512];
        decl String:entity[512];
        GetEntPropString(caller, Prop_Data, "m_iName", entity, sizeof(entity));
        GetClientName(attacker,user, sizeof(user));
        GetClientAuthString(attacker, userid, sizeof(userid));
        PrintToChatAll("Entity name: %s \nActivator: %s \nUserID: %s",entity,user,userid);
        return Plugin_Handled;
}

should be this i think
Code:

GetEntPropString(caller, Prop_Data, "m_iName", entity, sizeof(entity));
if (strcmp(entity,"NAME OF THE BUTTON IN THE MAP") == 0)
        {
            //DOWHAT YOU WANT (PrintToChat(client,"button XXX was pressed");
        }


RzGaming 12-08-2012 20:17

Re: CS:S Source Plugin Request.
 
i cant compile ur latest its a error

nikooo777 12-09-2012 08:46

Re: CS:S Source Plugin Request.
 
what kind of error? paste it with the [quote] tag

RzGaming 12-09-2012 23:40

Re: CS:S Source Plugin Request.
 
the one u sent me doenst work. i need a sm plugin coder who can fix this problem its must be showing only for Admins a button plugin that print [Buttonname] Playersname (STEAMID) Buttons name with fancy colors. i seing some zombie escape communitys use it thats why.

Nightshadow999 12-10-2012 22:49

Re: CS:S Source Plugin Request.
 
I've decompiled ze_sorrento_escape_v5 and noticed that Gargantua used func_rot_button instead of func_button. That's why the plugin didn't work on Gargantua maps. Added func_rot_button and also added/changed a few things from Nikooo777's code, thanks!

PHP Code:

#pragma semicolon 1
 
#include <sourcemod>
#include <sdktools>
#include <cstrike>
 
 
#define VERSION "1.0"
 
public Plugin:myinfo =
{
    
name "ZK Button Spam Preventer",
    
author "I3D Nightshadow",
    
description "Logs button presses to chat. Original author Silence, editted for ZK by i3D Nightshadow. Thx to nikooo777.",
    
version VERSION,
    
url "http://forum.i3d.net"
};
 
public 
OnMapStart()
{
    
CreateTimer1.0Hook_Buttons );
}
 
public 
Action:Hook_ButtonsHandle:Timer )
{
    
HookEntityOutput"func_button" "OnPressed"ButtonPressed );
    
HookEntityOutput"func_button" "OnDamaged"ButtonPressed );
    
HookEntityOutput"func_rot_button" "OnPressed"ButtonPressed );
    
HookEntityOutput"func_rot_button" "OnDamaged"ButtonPressed );
}
 
public 
ButtonPressed( const String:Output[], CallerActivatorFloat:Any )
{
    if( 
Activator && Activator MaxClients && IsClientConnected(Activator) && IsClientInGame(Activator)) 
    {
        
decl String:user[MAX_NAME_LENGTH];
        
decl String:steam[32];
        
decl String:entity[1024];
        
GetClientAuthString(Activatorsteamsizeof(steam));
        
GetClientName(Activator,usersizeof(user));
        
GetEntPropString(CallerProp_Data"m_iName"entitysizeof(entity));
        for (new 
1<= MaxClientsi++)
        {
            if( 
IsClientInGame(i) ) 
            {
                if( 
CheckCommandAccess(i"sm_chat"ADMFLAG_CHAT) )
                {
                    
PrintToChat(i"\x03[ZK-Button]\x01 %s(%s) pressed button: %s"usersteamentity );
                }
            }
        }
    }
    return 
Plugin_Handled;
}
 
public 
OnMapEnd()
{
    
UnhookEntityOutput"func_button" "OnPressed"ButtonPressed );
    
UnhookEntityOutput"func_button" "OnDamaged"ButtonPressed );
    
UnhookEntityOutput"func_rot_button" "OnPressed"ButtonPressed );
    
UnhookEntityOutput"func_rot_button" "OnDamaged"ButtonPressed );




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

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