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

Small pllugin for executing command on client, need help (code attached)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kempus
Member
Join Date: Jan 2016
Old 04-19-2016 , 12:13   Small pllugin for executing command on client, need help (code attached)
Reply With Quote #1

Hi, i writed a small plugin and the plugin itself is working, but... i got this message in my console "FCVAR_SERVER_CAN_EXECUTE prevented server running command: say"

Quote:
#include <sourcemod>
#include <sdktools>
#include <cstrike>

public bool:OnClientConnect(client, String:rejectmsg[], maxlen)
{
CreateTimer(120.0, Timer_Advertise, client);

return true;
}

public Action:Timer_Advertise(Handle:timer, any:client)
{
if (IsClientInGame(client))
ClientCommand(client,"say !advertisement");
else if (IsClientConnected(client))
CreateTimer(120.0, Timer_Advertise, client);
}

Last edited by Kempus; 04-19-2016 at 12:14.
Kempus is offline
Michael Shoe Maker
Senior Member
Join Date: Apr 2016
Old 04-19-2016 , 12:29   Re: Small pllugin for executing command on client, need help (code attached)
Reply With Quote #2

Some commands are restricted and therefore cannot be executed on a client.
Michael Shoe Maker is offline
Kempus
Member
Join Date: Jan 2016
Old 04-19-2016 , 12:32   Re: Small pllugin for executing command on client, need help (code attached)
Reply With Quote #3

Quote:
Originally Posted by Michael Shoe Maker View Post
Some commands are restricted and therefore cannot be executed on a client.
So, how can i execute command "say !advertisement" on client? Is there any way?
Kempus is offline
Michael Shoe Maker
Senior Member
Join Date: Apr 2016
Old 04-19-2016 , 12:39   Re: Small pllugin for executing command on client, need help (code attached)
Reply With Quote #4

Quote:
Originally Posted by Kempus View Post
So, how can i execute command "say !advertisement" on client? Is there any way?
You can't execute the say command via ClientCommand.
I wouldn't recommend the way you are trying to do it as it seems sloppy and an easy way to do things.

Use or create a way to send the advertisement all clients.

PHP Code:
public Action Timer_Advertise(Handle timerany client)
{
    for( 
int i 0GetMaxClients(); i++)
    {
        if(
IsClientInGame(i))
        {
            
//blah blah
        
}
    }


Last edited by Michael Shoe Maker; 04-19-2016 at 12:42.
Michael Shoe Maker is offline
Kempus
Member
Join Date: Jan 2016
Old 04-19-2016 , 12:59   Re: Small pllugin for executing command on client, need help (code attached)
Reply With Quote #5

Quote:
Originally Posted by Michael Shoe Maker View Post
You can't execute the say command via ClientCommand.
I wouldn't recommend the way you are trying to do it as it seems sloppy and an easy way to do things.

Use or create a way to send the advertisement all clients.

PHP Code:
public Action Timer_Advertise(Handle timerany client)
{
    for( 
int i 0GetMaxClients(); i++)
    {
        if(
IsClientInGame(i))
        {
            
//blah blah
        
}
    }

I don't understand anything. I am using the Web Shortcuts plugin, i have addes alias "!advertisement" and linked a site.

And i wan't to automatically execute this on client after x seconds from connect.
Kempus is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 04-19-2016 , 13:37   Re: Small pllugin for executing command on client, need help (code attached)
Reply With Quote #6

If you want a client to run say command to trigger an SM command, check out: https://sm.alliedmods.net/new-api/co...eClientCommand it also works on sm commands also, eg:
PHP Code:
FakeClientCommand(client"sm_admin"); 
above example will trigger the command "sm_admin" as if it was done in client's console.
WildCard65 is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 04-19-2016 , 14:04   Re: Small pllugin for executing command on client, need help (code attached)
Reply With Quote #7

Quote:
I am using the Web Shortcuts plugin, i have addes alias "!advertisement" and linked a site.
PHP Code:
CreateTimer(120.0Timer_Advertiseclient); 
I would not play on this server if there PvP or even PvE.

Quote:
I don't understand anything.
Something like
PHP Code:
public Action Timer_Advertise(Handle timerany client)
{
    for( 
int i 0GetMaxClients(); i++)
    {
        if(
IsClientInGame(i))
            
FakeClientCommand(i"sm_say !advertisement");
    }

__________________
Grey83 is offline
Phil25
AlliedModders Donor
Join Date: Feb 2015
Old 04-19-2016 , 14:32   Re: Small pllugin for executing command on client, need help (code attached)
Reply With Quote #8

Opening a window for a player every two minutes will defiantly make you loose them.

On a different note, I use WebShortcuts for a menu and can confirm that this works:
PHP Code:
FakeClientCommandEx(client"say donate2"); 
Edit: At least for Team Fortress 2.
Edit2: At least still.

Last edited by Phil25; 04-19-2016 at 14:34.
Phil25 is offline
Kempus
Member
Join Date: Jan 2016
Old 04-19-2016 , 14:58   Re: Small pllugin for executing command on client, need help (code attached)
Reply With Quote #9

IT WORKS! <3 <3 I LOVE YOU GUYS!

But one more stupid question, how to set to not execute this command to players with for example : "o" flag.

I did it like this:
Quote:
#include <sourcemod>
#include <sdktools>
#include <cstrike>

public bool:OnClientConnect(client, String:rejectmsg[], maxlen)
{
CreateTimer(120.0, Timer_Advertise, client);

return true;
}

public Action:Timer_Advertise(Handle:timer, any:client)
{
if (IsClientInGame(client))
FakeClientCommandEx(client, "say !reklama");
else if (IsClientConnected(client))
CreateTimer(120.0, Timer_Advertise, client);
}
Kempus is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 04-19-2016 , 15:02   Re: Small pllugin for executing command on client, need help (code attached)
Reply With Quote #10

Avoid using flags (evil - fakt zlo)... Use overrides - https://forums.alliedmods.net/showthread.php?t=183958 and https://forums.alliedmods.net/showthread.php?t=257809
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.
KissLick 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 05:57.


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