Raised This Month: $ Target: $400
 0% 

Top Awards!


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Maladca
Junior Member
Join Date: Mar 2014
Old 03-28-2014 , 09:38   Top Awards!
Reply With Quote #1

Hi, I need help!
I need to redo the plugin Top Awards.
This plugin gives players the admin flags, but only if the player is hit in the top15. And I need to just have so if a player will score in 1000 frags he gets the admin flags.

PHP Code:
/*
* Top Awards 10/22/2012


* Credits:
* - original plugin's authors SimonLogic & RoleX
* - c-s.net.ua users 3aB}{o3 & cs-portal for the idea and link
*/

#include <amxmodx>
#include <csstats>

#define IGNORE_FLAG ADMIN_LEVEL_A    /* flag "m" */

new pRankspFlags

public plugin_init() {
    
register_plugin"Top Awards""0.11c""Safety1st" )
    
register_dictionary"topawards.txt" )
    
pRanks register_cvar"top_ranks""10" )
    
pFlags register_cvar"top_flags""t" )
}

public 
client_putinserver(id) {
    
set_task0.3"CheckStats"id )    // we need to use delay otherwise we will get rank = 0
}

public 
CheckStats(id) {
    new 
iFlags get_user_flags(id)
    new 
szAddFlags[16]
    
get_pcvar_stringpFlagsszAddFlags15 )
    new 
iAddFlags  read_flags(szAddFlags)

    if ( 
iFlags IGNORE_FLAG || iFlags iAddFlags == iAddFlags )
        
// ignore player with IGNORE_FLAG or having all additional flags
        
return

    new 
iRanks get_pcvar_num(pRanks)
    if ( !
iRanks )
        return

    new 
szStats[8], szBodyHits[8]
    new 
iRank get_user_statsidszStatsszBodyHits )

    if ( 
iRank && iRank <= iRanks ) {
        
// 1st check for safety. may be player not ranked at all yet
        
set_user_flagsidiFlags iAddFlags )
        new 
data[2]
        
data[0] = id
        data
[1] = iRanks
        set_task
5.0"PrintMessage"_data)
    }
}

public 
PrintMessagedata[2] ) {
    if ( !
is_user_connected(data[0]) )
        return

    
ColorPrintdata[0], "%L"data[0], "TOP_AWARDS"data[1] )
}

ColorPrintiReceiver, const szRawMessage[ ], any:... ) {
    static 
iMsgSayText 0
    
if( !iMsgSayText )
        
iMsgSayText get_user_msgid"SayText" )

    new 
szMessage[192]
    
vformatszMessagecharsmax(szMessage) - 1szRawMessage)
    
replace_allszMessagecharsmax(szMessage) - 1"!n""^1" )
    
replace_allszMessagecharsmax(szMessage) - 1"!t""^3" )
    
replace_allszMessagecharsmax(szMessage) - 1"!g""^4" )
    if ( 
szMessage[0] != '^1' || szMessage[0] != '^3' || szMessage[0] != '^4' )
        
formatszMessagecharsmax(szMessage) - 1"^1%s"szMessage )    // we must set initial default color if it is not provided explicitly

    
message_beginMSG_ONE_UNRELIABLEiMsgSayText_iReceiver )
    
write_byte(iReceiver)    // use target player as sender to see colors at all (and his own team color for ^3)
    
write_string(szMessage)
    
message_end()

Attached Files
File Type: sma Get Plugin or Get Source (top_awards.sma - 694 views - 2.6 KB)

Last edited by Maladca; 03-28-2014 at 16:20.
Maladca is offline
 



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 05:59.


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