AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Check this code (https://forums.alliedmods.net/showthread.php?t=294321)

Lawnmoverman 02-24-2017 19:11

[HELP] Check this code
 
Hi, as I finally done with this plugin I would like that someone take a look at it and tell me is there something wrong, or is there any kind of issues. Plugin compiles with some minor warnings, I still not tested it on server. I wanted your opinions first. Please correct what you can, or let me know.

Here's plugin:

PHP Code:

/**
 * Nozgaming.eu VIP Management 1.0 (c) Lawnmoverman
 * www.nozgaming.eu | cs.nozgaming.eu
 *
 * Precache vip player models in your sub plugin
 * This plugin should be last in your plugins.ini list
**/

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <cstrike> 
#include <fun> 
#include <hamsandwich> 
#include <chatcolor>
#include <dhudmessage>

new UserName[32];
new 
SteamID[34];
new 
UserID[3];
new 
CsTeams:g_iTeam[33];
new 
bool:HasSite;

public 
plugin_init()
{
    
register_plugin("Nozgaming.eu VIP Management""1.0""Lawnmoverman");
    
register_event("TeamInfo""event_TeamInfo""a");
}

// Tell to all that VIP joined the server
public client_putinserver(id)
{
    if(
get_user_flags(id) & read_flags("s"))
    { 
        
get_user_name(idUserNamecharsmax(UserName));

        
client_print_color(00,"^3[Vip] ^4User^3 %s ^4have joined the server, ^3VIP ^4priveleges granted!"UserName);
    }
}

// Set VIP model to player
public fw_spawn_post(id
{
    if(
get_user_flags(id) & read_flags("s"))
    {
        if (!
is_user_alive(id)) 
            return 
HAM_IGNORED;

        new 
CsTeams:team cs_get_user_team(id); 
        
cs_set_user_model(idteam == CS_TEAM_CT "noz_vip_ct" "noz_vip_t"); // Your model names here 

        
return HAM_IGNORED;
    } 
}

// VIP extras on spawn
public player_spawn(id
{
    if(
get_user_flags(id) & read_flags("s"))
    {
        if (!
is_user_alive(id)) 

        
cs_set_user_money(id, (cs_get_user_money(id) + 500)); // Gives extra $500 on every spawn
        // Gives 2 flashbangs and 1 smokegrenade
        
give_item(id,"weapon_flashbang");
        
give_item(id,"weapon_flashbang");
        
give_item(id,"weapon_smokegrenade");

        
set_user_health(id120); // Sets user health to 120

        
set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,30); // Makes player semi transparent
        
set_task(5.0"renderNormal"id); // Makes player normal after 5 secs

        // Gives defuser if CT
        
if( is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT )
        {
            
cs_set_user_defuse(id1);
        } 
    } 
}

// Makes player rendering normal
public renderNormal(id)
{
    
set_user_rendering(idkRenderNormal);
}

// Events on VIP when changing team, or when joining team for the first time
public event_TeamInfo(id)
{
    if(
get_user_flags(id) & read_flags("s"))
    {    
        static 
sTeam[16];
        static const 
iTeamLen sizeof(sTeam) - 1;
        
read_data(2sTeamiTeamLen);
    
        static 
CsTeams:iTeam;
        switch(
sTeam[0])
        {
            case 
'U'iTeam CS_TEAM_UNASSIGNED;
            case 
'T'iTeam CS_TEAM_T;
            case 
'C'iTeam CS_TEAM_CT;
            case 
'S'iTeam CS_TEAM_SPECTATOR;
        }
    
        static 
idid read_data(1);
        if(
g_iTeam[id] != iTeam)
        {
            
// VIP joined new team
            
get_user_name(idUserNamecharsmax(UserName));

            if(
iTeam == CS_TEAM_T)
            {
                
// This will alert all players that VIP joined Ts
                
client_print_color(00,"^3[Vip] ^4User^3 %s ^4have joined the ^3Terrorists ^4team!"UserName);
            }
            if(
iTeam == CS_TEAM_CT)
            {
                
// This will alert all players that VIP joined CTs
                
client_print_color(00,"^3[Vip] ^4User^3 %s ^4have joined the ^3Counter-Terrorists ^4team!"UserName);
            }
            else
            {
                
// This will alert all players that VIP joined Spectators
                
client_print_color(00,"^3[Vip] ^4User^3 %s ^4have gone to ^3Spectators^4!"UserName);
            }

            if(
g_iTeam[id] == CS_TEAM_UNASSIGNED)
            {
            
// VIP joins team for the first time
            
set_task(10.0"alertPlayer"id);
            
set_task(10.0"setupVIP_3rdparty"id);
            }
        }
        
g_iTeam[id] = iTeam;
        return 
PLUGIN_CONTINUE;
    }
}

// This code alerts player that he is VIP, this is called after 10 secs, when player joins team for the first time 
public alertPlayer(id)
{
    
get_user_name(idUserNamecharsmax(UserName));
    
client_print_color(id0,"^3[Vip] ^4Welcome^3 %s ^4, you have ^3VIP ^4access, priveleges granted!"UserName);
    
set_dhudmessage4479255, -1.00.2526.03.00.11.5 );
    
show_dhudmessage(id"[Vip] Special priveleges granted!");
    
client_cmd(id"spk ^"access granted^"");
}

// Third party plugin commands to execute on VIP, when he joins team for the first time
public setupVIP_3rdparty(id)
{
    
server_cmd("amx_speed #%d ON 106"get_user_userid(id));
    
server_cmd("amx_autobhop #%d 1"get_user_userid(id));


Oh, and Please dont call me lame or smth. similar. Im still learning pawn.

yas17sin 02-24-2017 21:15

Re: [HELP] Check this code
 
errors fixed :
PHP Code:

/**
 * Nozgaming.eu VIP Management 1.0 (c) Lawnmoverman
 * www.nozgaming.eu | cs.nozgaming.eu
 *
 * Precache vip player models in your sub plugin
 * This plugin should be last in your plugins.ini list
**/

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <cstrike> 
#include <fun> 
#include <hamsandwich> 
#include <chatcolor>
#include <dhudmessage>

new UserName[32];
/*new SteamID[34];
new UserID[3];*/
new CsTeams:g_iTeam[33];
/*new bool:HasSite;*/

public plugin_init()
{
    
register_plugin("Nozgaming.eu VIP Management""1.0""Lawnmoverman");
    
register_event("TeamInfo""event_TeamInfo""a");
}

// Tell to all that VIP joined the server
public client_putinserver(id)
{
    if(
get_user_flags(id) & read_flags("s"))
    { 
        
get_user_name(idUserNamecharsmax(UserName));

        
client_print_color(00,"^3[Vip] ^4User^3 %s ^4have joined the server, ^3VIP ^4priveleges granted!"UserName);
    }
}

// Set VIP model to player
public fw_spawn_post(id
{
    if(
get_user_flags(id) & read_flags("s"))
    {
        if (!
is_user_alive(id)) 
            return 
HAM_IGNORED;
        
        new 
CsTeams:team cs_get_user_team(id); 
        
cs_set_user_model(idteam == CS_TEAM_CT "noz_vip_ct" "noz_vip_t"); // Your model names here 
        
        
return HAM_IGNORED;
    }
    return 
PLUGIN_HANDLED;
}

// VIP extras on spawn
public player_spawn(id
{
    if(
get_user_flags(id) & read_flags("s"))
    {
        if (!
is_user_alive(id)) 

        
cs_set_user_money(id, (cs_get_user_money(id) + 500)); // Gives extra $500 on every spawn
        // Gives 2 flashbangs and 1 smokegrenade
        
give_item(id,"weapon_flashbang");
        
give_item(id,"weapon_flashbang");
        
give_item(id,"weapon_smokegrenade");

        
set_user_health(id120); // Sets user health to 120

        
set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,30); // Makes player semi transparent
        
set_task(5.0"renderNormal"id); // Makes player normal after 5 secs

        // Gives defuser if CT
        
if( is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT )
        {
            
cs_set_user_defuse(id1);
        } 
    } 
}

// Makes player rendering normal
public renderNormal(id)
{
    
set_user_rendering(idkRenderNormal);
}

// Events on VIP when changing team, or when joining team for the first time
public event_TeamInfo(id)
{
    if(
get_user_flags(id) & read_flags("s"))
    {    
        static 
sTeam[16];
        static const 
iTeamLen sizeof(sTeam) - 1;
        
read_data(2sTeamiTeamLen);
        
        static 
CsTeams:iTeam;
        switch(
sTeam[0])
        {
            case 
'U'iTeam CS_TEAM_UNASSIGNED;
            case 
'T'iTeam CS_TEAM_T;
            case 
'C'iTeam CS_TEAM_CT;
            case 
'S'iTeam CS_TEAM_SPECTATOR;
        }
        
        static 
idid read_data(1);
        if(
g_iTeam[id] != iTeam)
        {
            
// VIP joined new team
            
get_user_name(idUserNamecharsmax(UserName));

            if(
iTeam == CS_TEAM_T)
            {
                
// This will alert all players that VIP joined Ts
                
client_print_color(00,"^3[Vip] ^4User^3 %s ^4have joined the ^3Terrorists ^4team!"UserName);
            }
            if(
iTeam == CS_TEAM_CT)
            {
                
// This will alert all players that VIP joined CTs
                
client_print_color(00,"^3[Vip] ^4User^3 %s ^4have joined the ^3Counter-Terrorists ^4team!"UserName);
            }
            else
            {
                
// This will alert all players that VIP joined Spectators
                
client_print_color(00,"^3[Vip] ^4User^3 %s ^4have gone to ^3Spectators^4!"UserName);
            }
            
            if(
g_iTeam[id] == CS_TEAM_UNASSIGNED)
            {
            
// VIP joins team for the first time
            
set_task(10.0"alertPlayer"id);
            
set_task(10.0"setupVIP_3rdparty"id);
            }
        }
        
g_iTeam[id] = iTeam;
        return 
PLUGIN_CONTINUE;
    }
    return 
PLUGIN_HANDLED;
}

// This code alerts player that he is VIP, this is called after 10 secs, when player joins team for the first time 
public alertPlayer(id)
{
    
get_user_name(idUserNamecharsmax(UserName));
    
client_print_color(id0,"^3[Vip] ^4Welcome^3 %s ^4, you have ^3VIP ^4access, priveleges granted!"UserName);
    
set_dhudmessage4479255, -1.00.2526.03.00.11.5 );
    
show_dhudmessage(id"[Vip] Special priveleges granted!");
    
client_cmd(id"spk ^"access granted^"");
}

// Third party plugin commands to execute on VIP, when he joins team for the first time
public setupVIP_3rdparty(id)
{
    
server_cmd("amx_speed #%d ON 106"get_user_userid(id));
    
server_cmd("amx_autobhop #%d 1"get_user_userid(id));



Lawnmoverman 02-25-2017 06:17

Re: [HELP] Check this code
 
Lots of code is not working, or is working not how it should be. I thing its my problem. Ill post new code as soon as I can fix it up.

yas17sin 02-25-2017 06:45

Re: [HELP] Check this code
 
i didn't test it i just did compile it, so ...

Lawnmoverman 02-25-2017 06:49

Re: [HELP] Check this code
 
I know, in fact I told that those are my errors. I need to tweak it better. Probably Im going to ask to someone to write the plugin for me with what I want. I suppose that I cant do it myself.

yas17sin 02-25-2017 06:52

Re: [HELP] Check this code
 
yeah, you did test the code or not ?

Lawnmoverman 02-25-2017 07:12

Re: [HELP] Check this code
 
I tested it but many things are not working at all or are working in wrong way.

yas17sin 02-25-2017 07:32

Re: [HELP] Check this code
 
any log or smth ?

Lawnmoverman 02-25-2017 07:36

Re: [HELP] Check this code
 
Well.

set_user_money is not working
all players are anonounced as vip
3rd party works for normal users and not vip
give nades are not working
player models are not working (neither with cl_minmodels 0)
render on round start is not working

this is for sure (id) problem, so I need to rewrite this completely

Lawnmoverman 02-25-2017 08:02

Re: [HELP] Check this code
 
Moved here https://forums.alliedmods.net/showthread.php?t=294338


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

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