Raised This Month: $ Target: $400
 0% 

IsPlayerAlive?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ae2x
Member
Join Date: Mar 2017
Old 03-06-2019 , 21:23   IsPlayerAlive?
Reply With Quote #1

Hi!

Is it possible make plugin that read from .txt file where you can add commands witch cant open only when player is alive?

Like !vip etc ..
ae2x is offline
Pilo
AlliedModders Donor
Join Date: Jan 2019
Location: Israel
Old 03-07-2019 , 02:29   Re: IsPlayerAlive?
Reply With Quote #2

You can’t make a command from a .txt file, You must make the command in the .sp of the plugin
Anyway you can get plugins of V.I.P in AlliedModders forum.
__________________

Taking Private(PAID) Plugins In PM
Feel free to Donate with PayPal
Feel free to message me in Discord Pilo#8253
Total donated : 25$
Pilo is offline
ae2x
Member
Join Date: Mar 2017
Old 03-07-2019 , 04:18   Re: IsPlayerAlive?
Reply With Quote #3

well that was not what i was looking for .. let me ask i again but different way


When you are spectating or dead you can type !vip or any trigger that is on the server and it will open menu right .. i want that to not happen so when you type example : !vip (i dont need that plugin) it will print to chat "You cannot use that command, you must be alive" and the point of .txt file that you can add those triggers there !vip , !join , !gun etc ..
ae2x is offline
CliptonHeist
Senior Member
Join Date: Feb 2016
Old 03-07-2019 , 14:48   Re: IsPlayerAlive?
Reply With Quote #4

Quote:
Originally Posted by ae2x View Post
well that was not what i was looking for .. let me ask i again but different way


When you are spectating or dead you can type !vip or any trigger that is on the server and it will open menu right .. i want that to not happen so when you type example : !vip (i dont need that plugin) it will print to chat "You cannot use that command, you must be alive" and the point of .txt file that you can add those triggers there !vip , !join , !gun etc ..
You can't add commands by a txt file, how do you expect the commands to have any functionality if you just write !vip in a file??

You need to do something like this for every command you want to create:
PHP Code:
public void OnPluginStart()
{
    
RegConsoleCmd("sm_vip"Command_VIP"Shows VIP Menu");
}

public 
Action Command_VIP(int Clientint iArgs)
{
    if(!
IsPlayerAlive(Client))
    {
        
PrintToChat(Client"You must be alive to use this command.");
        return 
Plugin_Handled;
    }

    
//rest of command code

CliptonHeist is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 03-07-2019 , 16:59   Re: IsPlayerAlive?
Reply With Quote #5

What I understand is that he wants to load some .txt or .cfg file (from data folder), or maybe through a convar, that contains which commands should be used only when "IsPlayerAlive(client)" is true.

Maybe this is possible through a listener

Try to check this thread.

If is what he wants, is think it's possible. But I'm not the best person to explain how-to.
Marttt is offline
Skyy
AlliedModders Donor
Join Date: Jan 2010
Location: Toronto, Canada
Old 03-07-2019 , 17:33   Re: IsPlayerAlive?
Reply With Quote #6

Quote:
Originally Posted by Pilo View Post
You can’t make a command from a .txt file, You must make the command in the .sp of the plugin
This is not true; you can create custom commands via kv using text files.
I do this, for example, so my source code looks like this:
Code:
GetConfigValue(thetext, sizeof(thetext), "rpg menu command?");
RegConsoleCmd(thetext, CMD_OpenRPGMenu);
__________________
Skyy is offline
ae2x
Member
Join Date: Mar 2017
Old 03-07-2019 , 19:26   Re: IsPlayerAlive?
Reply With Quote #7

Quote:
Originally Posted by Marttt View Post
What I understand is that he wants to load some .txt or .cfg file (from data folder), or maybe through a convar, that contains which commands should be used only when "IsPlayerAlive(client)" is true.

Maybe this is possible through a listener

Try to check this thread.

If is what he wants, is think it's possible. But I'm not the best person to explain how-to.
i think that can work
ae2x is offline
ae2x
Member
Join Date: Mar 2017
Old 03-07-2019 , 19:26   Re: IsPlayerAlive?
Reply With Quote #8

but i just learning sourcepawn so i dont know how to make it :S
ae2x is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 03-07-2019 , 21:10   Re: IsPlayerAlive?
Reply With Quote #9

Try this one. I made fast so maybe has some bugs

It worked for "!admin" on chat.

Put the "alive_commands.txt" on sourcemod\data folder
and the block_commands_not_alive.smx file on sourcemod\plugins folder

So you gonna have to edit the file with your commands

Looks like needs to be in this pattern "sm_*" where * is the command
Example: "sm_admin"

You must test on another places either, like running through console or "team chat" (say_team)

If it works I can make a polished version for you.

To reload the .txt file (for a while), type "sm plugins unload block_commands_not_alive.smx" on console
and then "sm plugins refresh" to update.

Repeat the process every time you update the .txt in game

Tested on a L4D2 server
Attached Files
File Type: sp Get Plugin or Get Source (block_commands_not_alive.sp - 239 views - 1.4 KB)
File Type: txt alive_commands.txt (10 Bytes, 95 views)

Last edited by Marttt; 03-21-2022 at 05:27.
Marttt 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 21:52.


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