AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help Plugin (https://forums.alliedmods.net/showthread.php?t=278814)

JoaoVieira 02-08-2016 15:25

Help Plugin
 
Hello :D, i need help , this plugin work's on my Jailbreak Server but it doesn't show the %hs , second is , if i put this plugin on my public server and write /rank , it doesn't appear on chat , can some one fix it pls?

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <csx>
#include <csstats>
#include <colorchat>

#define PLUGIN "User Stats"
#define VERSION "1.0"
#define AUTHOR "Sempz"

#define HEADSHOT_RATIO 0.50

new g_iHeadshots[33];

// this set's when the message will display again
#define advertisemystats     60.0 

new pcvar_mystats

new const g_Tag[ ] = "^04[SMART TEAM PORTUGAL]^01";


public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd"say /rank""FragsDeathsRatioMin" )
    
    
//ADVERTISE
    
pcvar_mystats register_cvar("sv_advertise""1");
    
    if(
get_cvar_num("sv_advertise") == 1)
    {
        
set_task(advertisemystats"advertise"___"b")
    }
}
public 
FragsDeathsRatioMin()
{
    new 
nick[33]
    new 
kId read_data);    // Killer Index
    
new iHeadshot read_data);
    new 
stats[8], body[8]
    new 
rank_pos get_user_stats(kIdstatsbody)
    new 
rank_max get_statsnum()
    
    
get_user_stats(kIdstatsbody)
    
get_statsnum()
    
    static 
Deaths 0Kills 0Float:Ratio 0.0
    Deaths 
stats[1], Kills stats[0], Ratio Deaths == ? (float(Kills)) : (float(Kills) / float(Deaths))
    
    
    if ( 
iHeadshot )
        
g_iHeadshots[kId] += 1;
    
    
// Display message if headshots > HEADSHOT_RATIO
    
    
new iKills get_user_fragskId );
    new 
Float:fRatio floatg_iHeadshots[kId] ) / floatiKills );
    
    if ( 
fRatio >= HEADSHOT_RATIO )
    {
        
get_user_name(kIdnick32)
        
ColorChat(kIdNORMAL"%s ^03%s^01 o teu ^04rank^01 e ^04%d^01 de ^04%d^01 com ^03%d^01 Frags ,^03%d^01 Mortes , KD: ^03%.2f^01 e ^03%0.0f%%^01 HS."g_Tagnickrank_pos,rank_maxstats[0], stats[1], RatiofRatio 100.0"%%" );
    }
}


//Advertise Connect
public client_putinserver(id)
{
    if(
get_pcvar_num(pcvar_mystats) == 1)
    {
        
set_task(10.0"connectmessage"id__"a"1)
    }
}

//this display the message after 10 seconds, you can edit this on line 111
public connectmessage(id)
{
    if(
is_user_connected(id))
    {
        new 
name[33]
        
get_user_name(idname32)
        
ColorChat(idNORMAL"%s ^03%s^01 Se escreveres ^04/rank^01 tu ves as ^03Frags^01 , ^03Deaths^01 e ^03KD^01."g_Tag name)
    }



EFFx 02-20-2016 19:25

Re: Help Plugin
 
Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <csx>
#include <csstats>
#include <colorchat>
 
#define PLUGIN "User Stats"
#define VERSION "1.0"
#define AUTHOR "Sempz"
 
#define HEADSHOT_RATIO 0.50
new g_iHeadshots[33];
// this set's when the message will display again
#define advertisemystats    60.0 
new pcvar_mystats
new const g_Tag[ ] = "^04[SMART TEAM PORTUGAL]^01";

public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
   
    register_clcmd( "say /rank", "FragsDeathsRatioMin" )
   
    //ADVERTISE
    pcvar_mystats = register_cvar("sv_advertise", "1");
   
    if(get_cvar_num("sv_advertise") == 1)
    {
        set_task(advertisemystats, "advertise", _, _, _, "b")
    }
}
public FragsDeathsRatioMin(id)
{
    new nick[33]
    new iHeadshot = read_data( 3 );
    new stats[8], body[8]
    new rank_pos = get_user_stats(id, stats, body)
    new rank_max = get_statsnum()
   
    get_user_stats(id, stats, body)
    get_statsnum()
   
    static Deaths = 0, Kills = 0, Float:Ratio = 0.0
    Deaths = stats[1], Kills = stats[0], Ratio = Deaths == 0 ? (float(Kills)) : (float(Kills) / float(Deaths))
   
   
    if ( iHeadshot )
        g_iHeadshots[id] += 1;
   
    // Display message if headshots > HEADSHOT_RATIO
   
    new iKills = get_user_frags( id );
    new Float:fRatio = float( g_iHeadshots[id] ) / float( iKills );
   
    if ( fRatio >= HEADSHOT_RATIO )
    {
        get_user_name(id, nick, 32)
        ColorChat(id, NORMAL, "%s ^03%s^01 o teu ^04rank^01 e ^04%d^01 de ^04%d^01 com ^03%d^01 Frags ,^03%d^01 Mortes , KD: ^03%.2f^01 e ^03%0.0f%%^01 HS.", g_Tag, nick, rank_pos,rank_max, stats[0], stats[1], Ratio, fRatio * 100.0, "%%" );
    }
}

//Advertise Connect
public client_putinserver(id)
{
    if(get_pcvar_num(pcvar_mystats) == 1)
    {
        set_task(10.0, "connectmessage", id, _, _, "a", 1)
    }
}
//this display the message after 10 seconds, you can edit this on line 111
public connectmessage(id)
{
    if(is_user_connected(id))
    {
        new name[33]
        get_user_name(id, name, 32)
        ColorChat(id, NORMAL, "%s ^03%s^01 Se escreveres ^04/rank^01 tu ves as ^03Frags^01 , ^03Deaths^01 e ^03KD^01.", g_Tag , name)
    }
}



All times are GMT -4. The time now is 09:26.

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