Raised This Month: $37 Target: $400
 9% 

Problems with my first plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Leopard96
New Member
Join Date: Jan 2019
Old Yesterday , 15:11   Problems with my first plugin
Reply With Quote #1

Hello Guys, first sry about my English...

Im new here ^^

Thats my First plugin and i dont know why its doesn´t work...

#include <sourcemod>
#pragma semicolon 1
#define ADMFLAG_CONVARS (1<<7) /**< Convenience macro for Admin_Convars as a FlagBit */

new Handle:g_cvar_PlayerLimit = INVALID_HANDLE; //Amount of Players Connected before Map is open.

//Cvar
public OnPluginStart(){
g_cvar_PlayerLimit = CreateConVar("sm_playerlimit", "12", "Number of players needed to open the Map.", 0, true, 0.0, true, 64.0);
}

//Funktion
public OnClientAuthorized(client, const String:auth[]){
if(GetClientCount() >= GetConVarInt(g_cvar_PlayerLimit)) {
PrintToChatAll("Es sind mehr als 12 Spieler online, Map ist jetzt offen... map is open now");
AutoExecConfig(true, "dod_donner_og/dod_donner_og_open.cfg");
}
}
public OnClientDisconnect(client){
if(GetClientCount() < GetConVarInt(g_cvar_PlayerLimit)){
PrintToChatAll("Es sind weniger als 12 Spieler online... ONLY GARDEN!");
AutoExecConfig(true, "dod_donner_og/dod_donner_og_close.cfg");
}
}


I want thats when more than 12 players on the server the map dod_donner is complete open..
when less than 12 Players.. the map is blocked only garden is activated..

for that i want thats my plugin execute 2 cfg´s in there i write the sm_activate or sm_diactivate (from roots zone plugin)

i compeline with no error and i see if i do sm plugins list thats my plugin loaded.

but its do nothing...

when i execute the config path its worked..


what i do wrong.. can someone help me please

greetings Leopard
Leopard96 is offline
quasemago
Junior Member
Join Date: Dec 2018
Location: Brazil
Old Yesterday , 21:54   Re: Problems with my first plugin
Reply With Quote #2

First, use PHP tag in code.
Second, use ServerCommand.

PHP Code:
public void OnClientPutInServer(int client)
{
    if (
GetClientCount() >= GetConVarInt(g_cvar_PlayerLimit))
    {
        
PrintToChatAll("Es sind mehr als %d Spieler online, Map ist jetzt offen... map is open now"GetConVarInt(g_cvar_PlayerLimit));
        
ServerCommand("exec dod_donner_og/dod_donner_og_open.cfg");
    }
}

public 
void OnClientDisconnect_Post(int client)
{
    if (
GetClientCount() < GetConVarInt(g_cvar_PlayerLimit))
    {
        
PrintToChatAll("Es sind weniger als 12 Spieler online... ONLY GARDEN!");
        
ServerCommand("exec dod_donner_og/dod_donner_og_close.cfg");
    }


Last edited by quasemago; Yesterday at 21:57.
quasemago is offline
Lubricant Jam
AlliedModders Donor
Join Date: Oct 2016
Location: United Kingdom
Old Today , 05:24   Re: Problems with my first plugin
Reply With Quote #3

This would also be best off in the Scripting area of the site.
Lubricant Jam is offline
impossible_cc
Member
Join Date: Sep 2018
Location: Ukraine
Old Today , 18:58   Re: Problems with my first plugin
Reply With Quote #4

Quote:
Originally Posted by quasemago View Post
First, use PHP tag in code.
Second, use ServerCommand.

PHP Code:
public void OnClientPutInServer(int client)
{
    if (
GetClientCount() >= GetConVarInt(g_cvar_PlayerLimit))
    {
        
PrintToChatAll("Es sind mehr als %d Spieler online, Map ist jetzt offen... map is open now"GetConVarInt(g_cvar_PlayerLimit));
        
ServerCommand("exec dod_donner_og/dod_donner_og_open.cfg");
    }
}

public 
void OnClientDisconnect_Post(int client)
{
    if (
GetClientCount() < GetConVarInt(g_cvar_PlayerLimit))
    {
        
PrintToChatAll("Es sind weniger als 12 Spieler online... ONLY GARDEN!");
        
ServerCommand("exec dod_donner_og/dod_donner_og_close.cfg");
    }

Message can be printed and config can be executed multiple times in a row with your code, if 12th player joins <EXECUTE> then 13th player joins <Execute> etc...



PHP Code:
public void OnClientPutInServer(int client)
{
    if (
GetClientCount() == GetConVarInt(g_cvar_PlayerLimit))
    {
        
PrintToChatAll("Es sind mehr als %d Spieler online, Map ist jetzt offen... map is open now"GetConVarInt(g_cvar_PlayerLimit));
        
ServerCommand("exec dod_donner_og/dod_donner_og_open.cfg");
    }
}

public 
void OnClientDisconnect_Post(int client)
{
    if (
GetClientCount() + ==GetConVarInt(g_cvar_PlayerLimit))
    {
        
PrintToChatAll("Es sind weniger als 12 Spieler online... ONLY GARDEN!");
        
ServerCommand("exec dod_donner_og/dod_donner_og_close.cfg");
    }


Last edited by impossible_cc; Today at 18:59.
impossible_cc is online now
Reply


Thread Tools
Display Modes

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 19:12.


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