Raised This Month: $ Target: $400
 0% 

I need help!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Maladca
Junior Member
Join Date: Mar 2014
Old 03-29-2014 , 19:14   I need help!
Reply With Quote #1

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()

Maladca is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 03-29-2014 , 20:59   Re: I need help!
Reply With Quote #2

Code:
if ( iRank && iRank <= iRanks ) {
->
Code:
if ( iRank && iRank <= iRanks || szStats[0] > 1000 ) {
__________________
Black Rose is offline
Maladca
Junior Member
Join Date: Mar 2014
Old 03-30-2014 , 05:00   Re: I need help!
Reply With Quote #3

Quote:
Originally Posted by Black Rose View Post
Code:
if ( iRank && iRank <= iRanks ) {
->
Code:
if ( iRank && iRank <= iRanks || szStats[0] > 1000 ) {
Thank you very much. Question whether it is possible to make the player shows a message in each round for example: Your frags 750-322, after 1000 frags you get admin.
Maladca is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 03-30-2014 , 07:52   Re: I need help!
Reply With Quote #4

Somewhere along the lines of...
Code:
// Add this in plugin_init() register_event("HLTV", "eventNewRound", "a", "1=0", "2=0"); // Add this in global. public eventNewRound()     set_task(2.0, "delayedMessage"); public delayedMessage() {     new players[32], playersnum;     get_players(players, playersnum, "ch");     new szStats[8], szBodyHits[8], iRank;         for ( new i ; i < playersnum ; i++ ) {         iRank = get_user_stats( id, szStats, szBodyHits )         if ( szStats[0] < 1000 )             ColorPrint(players[i], "Your frags %d - %d, after 1000 frags you get admin", szStats[0], szStats[1]);     } } }
__________________
Black Rose is offline
Maladca
Junior Member
Join Date: Mar 2014
Old 03-30-2014 , 09:11   Re: I need help!
Reply With Quote #5

Quote:
Originally Posted by Black Rose View Post
Somewhere along the lines of...
Code:
// Add this in plugin_init() register_event("HLTV", "eventNewRound", "a", "1=0", "2=0"); // Add this in global. public eventNewRound()     set_task(2.0, "delayedMessage"); public delayedMessage() {     new players[32], playersnum;     get_players(players, playersnum, "ch");     new szStats[8], szBodyHits[8], iRank;         for ( new i ; i < playersnum ; i++ ) {         iRank = get_user_stats( id, szStats, szBodyHits )         if ( szStats[0] < 1000 )             ColorPrint(players[i], "Your frags %d - %d, after 1000 frags you get admin", szStats[0], szStats[1]);     } } }
After receiving the message the admin will show yet?
Maladca is offline
Maladca
Junior Member
Join Date: Mar 2014
Old 03-30-2014 , 09:23   Re: I need help!
Reply With Quote #6

Quote:
#include <amxmodx>
#include <csstats>

#define ignore_flag admin_level_a /* flag "m" */

new pranks, pflags

public plugin_init() {
register_plugin( "awards", "1.0", "nevermore" )
register_dictionary( "topawards.txt" )
pflags = register_cvar( "top_flags", "t" )
}

public client_putinserver(id) {
set_task( 0.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_string( pflags, szaddflags, 15 )
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]
if ( irank && irank <= iranks || szstats[0] > 1000 ) {

if ( irank && irank <= iranks ) {
// 1st check for safety. May be player not ranked at all yet
set_user_flags( id, iflags | iaddflags )
new data[2]
data[0] = id
data[1] = iranks
set_task( 5.0, "printmessage", _, data, 2 )
}
}

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

colorprint( data[0], "%l", data[0], "top_awards", data[1] )
}

colorprint( ireceiver, const szrawmessage[ ], any:... ) {
static imsgsaytext = 0
if( !imsgsaytext )
imsgsaytext = get_user_msgid( "saytext" )

new szmessage[192]
vformat( szmessage, charsmax(szmessage) - 1, szrawmessage, 3 )
replace_all( szmessage, charsmax(szmessage) - 1, "!n", "^1" )
replace_all( szmessage, charsmax(szmessage) - 1, "!t", "^3" )
replace_all( szmessage, charsmax(szmessage) - 1, "!g", "^4" )
if ( szmessage[0] != '^1' || szmessage[0] != '^3' || szmessage[0] != '^4' )
format( szmessage, charsmax(szmessage) - 1, "^1%s", szmessage ) // we must set initial default color if it is not provided explicitly

message_begin( msg_one_unreliable, imsgsaytext, _, 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()
}

// add this in plugin_init()
register_event("hltv", "eventnewround", "a", "1=0", "2=0");
// add this in global.
Public eventnewround()
set_task(2.0, "delayedmessage");

public delayedmessage() {
new players[32], playersnum;
get_players(players, playersnum, "ch");
new szstats[8], szbodyhits[8], irank;

for ( new i ; i < playersnum ; i++ ) {
irank = get_user_stats( id, szstats, szbodyhits )
if ( szstats[0] < 1000 )
colorprint(players[i], "your frags %d - %d, after 1000 frags you get admin", szstats[0], szstats[1]);
}
}
}
Gives out a mistake

Last edited by Maladca; 03-30-2014 at 09:23.
Maladca is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 03-30-2014 , 09:59   Re: I need help!
Reply With Quote #7

Sorry about that, here's the complete version.
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 pRanks, pFlags 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" )     register_event("HLTV", "eventNewRound", "a", "1=0", "2=0"); } public client_putinserver(id) {     set_task( 0.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_string( pFlags, szAddFlags, 15 )     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_stats( id, szStats, szBodyHits )     if ( iRank && iRank <= iRanks ) {         // 1st check for safety. may be player not ranked at all yet         set_user_flags( id, iFlags | iAddFlags )         new data[2]         data[0] = id         data[1] = iRanks         set_task( 5.0, "PrintMessage", _, data, 2 )     } } public PrintMessage( data[2] ) {     if ( !is_user_connected(data[0]) )     return     ColorPrint( data[0], "%L", data[0], "TOP_AWARDS", data[1] ) } public eventNewRound()     set_task(2.0, "delayedMessage"); public delayedMessage() {     new players[32], playersnum;     get_players(players, playersnum, "ch");     new szStats[8], szBodyHits[8];         for ( new i ; i < playersnum ; i++ ) {         get_user_stats( players[i], szStats, szBodyHits )         if ( szStats[0] < 1000 )         ColorPrint(players[i], "Your frags %d - %d, after 1000 frags you get admin", szStats[0], szStats[1]);     } } ColorPrint( iReceiver, const szRawMessage[ ], any:... ) {     static iMsgSayText = 0     if( !iMsgSayText )     iMsgSayText = get_user_msgid( "SayText" )     new szMessage[192]     vformat( szMessage, charsmax(szMessage) - 1, szRawMessage, 3 )     replace_all( szMessage, charsmax(szMessage) - 1, "!n", "^1" )     replace_all( szMessage, charsmax(szMessage) - 1, "!t", "^3" )     replace_all( szMessage, charsmax(szMessage) - 1, "!g", "^4" )     if ( szMessage[0] != '^1' || szMessage[0] != '^3' || szMessage[0] != '^4' )     format( szMessage, charsmax(szMessage) - 1, "^1%s", szMessage )    // we must set initial default color if it is not provided explicitly     message_begin( MSG_ONE_UNRELIABLE, iMsgSayText, _, 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() }
__________________
Black Rose is offline
Old 03-30-2014, 14:26
Maladca
This message has been deleted by Maladca.
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 06:03.


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