Raised This Month: $ Target: $400
 0% 

First time scripting error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
rameyaj
Junior Member
Join Date: Feb 2010
Old 10-11-2012 , 03:43   First time scripting error
Reply With Quote #1

hello all this is my first time scripting anything
i found a random plugin someone posted that works great
but i need to make it admins only the server i am going to run at our lan party is a overwhelming number of bots vs us and i would like to mod a few of my plugins for just players not bot
so i found a plugin thats admin only and tried to splice it into the plugin and this is what i came up with

Code:
#include <clients>

new add; 

new AdminFlag:cflag;

public OnPluginStart() 
{ 
    new Handle:cvar = CreateConVar("sm_kill_add_hp", "0", "Give this much HP every kill", FCVAR_NONE, true, 0.0); 
    add = GetConVarInt(cvar); 
    HookConVarChange(cvar, convar_changed); 
    CloseHandle(cvar); 

    HookEventEx("player_death", player_death); 
} 

public convar_changed(Handle:convar, const String:oldValue[], const String:newValue[]) 
{ 
    add = StringToInt(newValue); // Note, cvar sm_kill_add_hp was limited to minimum 0.0 
} 

public player_death(Handle:event, const String:name[], bool:dontBroadcast) 
{ 
    if(!add) // Disabled 
    { 
        return; 
    } 
    new client_userid = GetEventInt(event, "userid");
    new client = GetClientOfUserId(client_userid);
    
    new AdminId:admin_id = GetUserAdmin(client);
    {
    new attacker = GetClientOfUserId(GetEventInt(event, "attacker")); 
    if(attacker != 0) // Not killed by world or else non-player 
    { 
        new victim = GetClientOfUserId(GetEventInt(event, "userid")); 
        if(attacker != victim) // Not suicide 
        { 
            if(!victim || GetClientTeam(attacker) != GetClientTeam(victim)) // Victim perhaps monster in TF2 ?? or Not team kill 
            { 
                if (admin_id != INVALID_ADMIN_ID && IsClientInGame(client) && GetAdminFlag(admin_id, cflag, AdmAccessMode:Access_Effective))
                {
                    SetEntityHealth(attacker, GetClientHealth(attacker) + add); 
            } 
        } 
    } 
}
error 030: compound statement not closed at the end of file (started at line 33)

please help our party is Saturday... oh and i can post working plugin if need be
also if anyone knows of a easier way of making a plugin "not a command" work for just selected players or admins i would save me some time as well "have a few more that need this also"
thank

Last edited by rameyaj; 10-11-2012 at 03:56.
rameyaj is offline
ojmdk476oj
AlliedModders Donor
Join Date: Dec 2009
Old 10-11-2012 , 03:48   Re: First time scripting error
Reply With Quote #2

Maybe this will compile?

PHP Code:
#include <clients>

new add

new 
AdminFlag:cflag;

public 
OnPluginStart() 

    new 
Handle:cvar CreateConVar("sm_kill_add_hp""0""Give this much HP every kill"FCVAR_NONEtrue0.0); 
    
add GetConVarInt(cvar); 
    
HookConVarChange(cvarconvar_changed); 
    
CloseHandle(cvar); 

    
HookEventEx("player_death"player_death); 


public 
convar_changed(Handle:convar, const String:oldValue[], const String:newValue[]) 

    
add StringToInt(newValue); // Note, cvar sm_kill_add_hp was limited to minimum 0.0 


public 
player_death(Handle:event, const String:name[], bool:dontBroadcast

    if(!
add// Disabled 
    

        return; 
    }
    
    new 
client_userid GetEventInt(event"userid");
    new 
client GetClientOfUserId(client_userid);
    
    new 
AdminId:admin_id GetUserAdmin(client);
    
    new 
attacker GetClientOfUserId(GetEventInt(event"attacker")); 
    
    if(
attacker != 0// Not killed by world or else non-player 
    

        new 
victim GetClientOfUserId(GetEventInt(event"userid")); 
        if(
attacker != victim// Not suicide 
        

            if(!
victim || GetClientTeam(attacker) != GetClientTeam(victim)) // Victim perhaps monster in TF2 ?? or Not team kill 
            

                if (
admin_id != INVALID_ADMIN_ID && IsClientInGame(client) && GetAdminFlag(admin_idcflagAdmAccessMode:Access_Effective))
                {
                    
SetEntityHealth(attackerGetClientHealth(attacker) + add); 
            } 
        } 
    } 

ojmdk476oj is offline
rameyaj
Junior Member
Join Date: Feb 2010
Old 10-11-2012 , 03:57   Re: First time scripting error
Reply With Quote #3

nope it did not
/groups/sourcemod/upload_tmp/textWQSlua.sp(49) : error 030: compound statement not closed at the end of file (started at line 24) 1 Error.
rameyaj is offline
karq
Member
Join Date: Dec 2009
Old 10-11-2012 , 04:08   Re: First time scripting error
Reply With Quote #4

Try it:
PHP Code:
#include <clients> 

new add;  

new 
AdminFlag:cflag

public 
OnPluginStart()  
{  
    new 
Handle:cvar CreateConVar("sm_kill_add_hp""0""Give this much HP every kill"FCVAR_NONEtrue0.0);  
    
add GetConVarInt(cvar);  
    
HookConVarChange(cvarconvar_changed);  
    
CloseHandle(cvar);  

    
HookEventEx("player_death"player_death);  
}  

public 
convar_changed(Handle:convar, const String:oldValue[], const String:newValue[])  
{  
    
add StringToInt(newValue); // Note, cvar sm_kill_add_hp was limited to minimum 0.0  
}  

public 
player_death(Handle:event, const String:name[], bool:dontBroadcast)  
{  
    if(!
add// Disabled  
    
{  
        return;  
    } 
     
    new 
client_userid GetEventInt(event"userid"); 
    new 
client GetClientOfUserId(client_userid); 
     
    new 
AdminId:admin_id GetUserAdmin(client); 
     
    new 
attacker GetClientOfUserId(GetEventInt(event"attacker"));  
     
    if(
attacker != 0// Not killed by world or else non-player  
    
{  
        new 
victim GetClientOfUserId(GetEventInt(event"userid"));  
        if(
attacker != victim// Not suicide  
        
{  
            if(!
victim || GetClientTeam(attacker) != GetClientTeam(victim)) // Victim perhaps monster in TF2 ?? or Not team kill  
            
{  
                if (
admin_id != INVALID_ADMIN_ID && IsClientInGame(client) && GetAdminFlag(admin_idcflagAdmAccessMode:Access_Effective)) 
                { 
                    
SetEntityHealth(attackerGetClientHealth(attacker) + add);  
                }
            }  
        }  
    }  

karq is offline
TheHardstyleBro
Senior Member
Join Date: Jun 2012
Location: Netherlands
Old 10-11-2012 , 04:43   Re: First time scripting error
Reply With Quote #5

You forgot something to close with an
PHP Code:

__________________
TheHardstyleBro is offline
rameyaj
Junior Member
Join Date: Feb 2010
Old 10-11-2012 , 11:00   Re: First time scripting error
Reply With Quote #6

ok it worked but the plugin stoped working... i still have the working code its

Code:
new add; 

public OnPluginStart() 
{ 
    new Handle:cvar = CreateConVar("sm_kill_add_hp", "0", "Give this much HP every kill", FCVAR_NONE, true, 0.0); 
    add = GetConVarInt(cvar); 
    HookConVarChange(cvar, convar_changed); 
    CloseHandle(cvar); 

    HookEventEx("player_death", player_death); 
} 

public convar_changed(Handle:convar, const String:oldValue[], const String:newValue[]) 
{ 
    add = StringToInt(newValue); // Note, cvar sm_kill_add_hp was limited to minimum 0.0 
} 

public player_death(Handle:event, const String:name[], bool:dontBroadcast) 
{ 
    if(!add) // Disabled 
    { 
        return; 
    } 

    new attacker = GetClientOfUserId(GetEventInt(event, "attacker")); 
    if(attacker != 0) // Not killed by world or else non-player 
    { 
        new victim = GetClientOfUserId(GetEventInt(event, "userid")); 
        if(attacker != victim) // Not suicide 
        { 
            if(!victim || GetClientTeam(attacker) != GetClientTeam(victim)) // Victim perhaps monster in TF2 ?? or Not team kill 
            { 
                SetEntityHealth(attacker, GetClientHealth(attacker) + add); 
            } 
        } 
    } 
}
This is the working script it makes it so when any player gets a kill he is awarded the hp set in the cvar

is there a simple script i can add to this or is there a way i can use admin_overrides.cfg to make a plug in not a "command" work for admins and not other players well... "bots mainly"
rameyaj is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-11-2012 , 11:29   Re: First time scripting error
Reply With Quote #7

pls people, practise to use CheckCommandAccess.
You can override this "access" without editing plugin again.

Override-command is sm_killaddhp and flagged to "c"(kick) by default.
Spoiler
Bacardi is offline
rameyaj
Junior Member
Join Date: Feb 2010
Old 10-11-2012 , 15:49   Re: First time scripting error
Reply With Quote #8

sorry for not replying sooner i am at work on break
i just want to say thank you all so much i spent time searching how to make this admin only for about 6 + hours so far and also trying/failing to script it i can't wait to try this when i get home
i will try this anyways in no one replies but will adding the line
if(CheckCommandAccess(attacker, "sm_killaddhp", ADMFLAG_KICK))
to other plugins like to this one have the same affect "making them admin"
just wanted to say thanks again you saved me so much time/sleep
rameyaj 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 00:49.


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