Dabar yra 2018 Geg 26 23:28

Visos datos yra UTC + 2 valandos


Forumo taisyklės


1. Pluginai turi turėti išsamius aprašymus.
2. Aprašymai turi būti lietuvių kalba.



 Puslapis 11 [ 5 pranešimai(ų) ] 
Autorius Žinutė
 Pranešimo tema: Basic SkillPoints v2.0.2 [šiek tiek redaguotas]
Žinutės numeris: #1  StandartinėParašytas: 2017 Sau 16 01:51 
O taip. Jis jau surinko 50 žinučių!
Vartotojo avataras

Užsiregistravo: 2016 Rgs 06 23:57
Pranešimai: 62
Karma: 2
Nors dar visai nesenai pradėjau kažką konstruoti pluginuose, bet norėtūsi kažką ir duoti kitiems ne tik imti.

Orginalus pluginas: Basic SkillPoints v2.0.2 SE with API

Prisitaikiau taip kaip man reikėjo, pakeista:
  • Prefix'as chate pagal žaidėjo lygį (kiek pamenu kodas apibūdina plugino elgesį tik jei žaidėjas T arba CT komandoje t.y. bbž ką rašys kai žaidėjas bus spec.)
  • Žaidėjo informacijos saugorimas ant nicko (pats naudoju SQL versiją šio plugino, tai man informaciją saugo authid > žaidėjo_nickas (seniau buvo steam id) ir yra kitas toks pat laukelis nick kur taip pat saugo žaidėjo nicką)
    saugojimo tipą galit pasikeist 295 eilutėj.
    1. get_user_name( id , g_szAuthID[ id ], charsmax( g_szAuthID[ ] ) )


    ai ir dar užkomentavau
    //register_concmd( "bps_give", "CmdGivePoints", ADMIN, "<target> <skillpoints to give>" )
    //register_concmd( "bps_take", "CmdTakePoints", ADMIN, "<target> <skillpoints to take>" )
    žaiskite sąžiningai


BasicSkillPointsSQL_SE.sma
  1. #include < amxmodx >
  2. #include < amxmisc >
  3. #include < cstrike >
  4. #include < csx >
  5. #include < hamsandwich >
  6. #include < sqlx >
  7.  
  8. #define PLUGIN      "Basic SkillPoints Special Edition (SQL)"
  9. #define VERSION     "2.0.2"
  10. #define AUTHOR      "guipatinador"
  11.  
  12. #define SQL_TABLE   "skillpoints_v2"
  13. #define PREFIX      "[SkillPoints]"
  14.  
  15. #define MAX_PLAYERS 32
  16. #define ADMIN       ADMIN_RCON
  17. #define CONNECT_TASK    1024
  18.  
  19. #define MAX_CLASSES 2
  20. #define MAX_LEVELS  2
  21. #define MAX_PONTUATION  10000 // max skillpoints per player
  22.  
  23. #define IsPlayer(%1)        ( 1 <= %1 <= g_iMaxPlayers )
  24.  
  25. new const CLASSES[ MAX_CLASSES ][ ] = {
  26.     "Jaunesnysis BOTAS",
  27.     "BOTAS",
  28. }
  29.  
  30. new const LEVELS[ MAX_LEVELS ] = {
  31.     200,
  32.     500
  33. }
  34.  
  35. new g_iK
  36. new const g_ChatAdvertise[ ][ ] = {
  37.     "!g%s!n Write!t /myskill!n to see your SkillPoints",
  38.     "!g%s!n Write!t /restartskill!n to restart your SkillPoints and level",
  39.     "!g%s!n Write!t /rankskill!n to see your rank",
  40.     "!g%s!n Write!t /topskill!n to see the top SkillPointers"
  41. }
  42.  
  43. new g_iMaxPlayers
  44. new g_szAuthID[ MAX_PLAYERS + 1 ][ 35 ]
  45. new g_szName[ MAX_PLAYERS + 1 ][ 32 ]
  46.  
  47. new Handle:g_SqlTuple
  48. new g_iCount
  49. new g_iRank[ MAX_PLAYERS + 1 ]
  50. new g_iCurrentKills[ MAX_PLAYERS + 1 ]
  51. new g_szMotd[ 1536 ]
  52.  
  53. new g_pcvarHost
  54. new g_pcvaruUser
  55. new g_pcvarPass
  56. new g_pcvarDB
  57.  
  58. new g_iPoints[ MAX_PLAYERS + 1 ]
  59. new g_iLevels[ MAX_PLAYERS + 1 ]
  60. new g_iClasses[ MAX_PLAYERS + 1 ]
  61.  
  62. new g_iKills[ MAX_PLAYERS + 1 ]
  63. new g_iDeaths[ MAX_PLAYERS + 1 ]
  64. new g_iHeadShots[ MAX_PLAYERS + 1 ]
  65. new g_iKnifeKills[ MAX_PLAYERS + 1 ]
  66. new g_iKnifeDeaths[ MAX_PLAYERS + 1 ]
  67. new g_iGrenadeKills[ MAX_PLAYERS + 1 ]
  68. new g_iGrenadeDeaths[ MAX_PLAYERS + 1 ]
  69. new g_iBombExplosions[ MAX_PLAYERS + 1 ]
  70. new g_iDefusedBombs[ MAX_PLAYERS + 1 ]
  71. new g_iWonRounds[ MAX_PLAYERS + 1 ]
  72.  
  73. new g_TimeBetweenAds
  74.  
  75. new bool:g_bRoundEnded
  76.  
  77. new g_iAdsOnChat
  78. new g_iEnableAnnounceOnChat
  79. new g_iEnableShowSkillPointsOnNick
  80. new g_iHideChangeNickNotification
  81. new g_iEnableSkillPointsCmd
  82. new g_iEnableSkillPointsRestart
  83. new g_iEnableSkillPointsCmdRank
  84. new g_iEnableSkillPointsTop15
  85. new g_iHideCmds
  86. new g_iEnableWonPointsHour
  87. new g_iWonPointsHour
  88. new g_iLostPointsTK
  89. new g_iLostPointsSuicide
  90. new g_iWonPointsKill
  91. new g_iLostPointsDeath
  92. new g_iWonPointsHeadshot
  93. new g_iLostPointsHeadshot
  94. new g_iWonPointsKnife
  95. new g_iLostPointsKnife
  96. new g_iWonPointsGrenade
  97. new g_iLostPointsGrenade
  98. new g_iWonPointsTerrorists
  99. new g_iWonPointsCounterTerrorists
  100. new g_iLostPointsTerrorists
  101. new g_iLostPointsCounterTerrorists
  102. new g_iWonPointsPlanter
  103. new g_iWonPointsPlanterExplode
  104. new g_iWonPointsDefuser
  105. new g_iWonPoints4k
  106. new g_iWonPoints5k
  107. new g_iNegativePoints
  108.  
  109. public plugin_init( )
  110. {
  111.     register_plugin( PLUGIN, VERSION, AUTHOR )
  112.    
  113.     register_clcmd( "say", "ClCmd_Say" )
  114.     register_clcmd( "say_team", "ClCmd_Say_team" )
  115.    
  116.     //register_concmd( "bps_give", "CmdGivePoints", ADMIN, "<target> <skillpoints to give>" )
  117.     //register_concmd( "bps_take", "CmdTakePoints", ADMIN, "<target> <skillpoints to take>" )
  118.    
  119.     RegisterHam( Ham_Spawn, "player", "FwdPlayerSpawnPost", 1 )
  120.    
  121.     register_message( get_user_msgid( "SayText" ), "MessageSayText" )
  122.    
  123.     register_event( "SendAudio", "TerroristsWin", "a", "2&%!MRAD_terwin" )
  124.     register_event( "SendAudio", "CounterTerroristsWin", "a", "2&%!MRAD_ctwin" )
  125.    
  126.     register_event( "HLTV", "EventNewRound", "a", "1=0", "2=0" )
  127.     register_logevent( "EventRoundEnd", 2, "1=Round_End" )
  128.    
  129.     g_iMaxPlayers = get_maxplayers( )
  130.    
  131.     RegisterCvars( )
  132.     SqlInit( )
  133. }
  134.  
  135. public plugin_natives( )
  136. {
  137.     register_library( "skillpoints" )
  138.    
  139.     register_native( "skillpoints", "_skillpoints" )
  140. }
  141.  
  142.  
  143. public _skillpoints( plugin, params )
  144. {
  145.     if( params != 1 )
  146.     {
  147.         return 0
  148.     }
  149.    
  150.     new id = get_param( 1 )
  151.     if( !id )
  152.     {
  153.         return 0
  154.     }
  155.    
  156.     return g_iPoints[ id ]
  157. }
  158.  
  159. public RegisterCvars( )
  160. {
  161.     g_iAdsOnChat = register_cvar( "bps_ads", "1" )
  162.     g_TimeBetweenAds = register_cvar( "bps_time_between_ads", "300.0" )
  163.     g_iEnableAnnounceOnChat = register_cvar( "bps_announce_on_chat", "1" )
  164.     g_iEnableShowSkillPointsOnNick = register_cvar( "bps_skillpoints_on_nick", "1" )
  165.     g_iHideChangeNickNotification = register_cvar( "bps_hide_change_nick_notification", "1" )
  166.     g_iEnableSkillPointsCmd = register_cvar( "bps_skillpoints_cmd", "1" )
  167.     g_iEnableSkillPointsRestart = register_cvar( "bps_skillpoints_cmd_restart", "1" )
  168.     g_iEnableSkillPointsCmdRank = register_cvar( "bps_skillpoints_cmd_rank", "1" )
  169.     g_iEnableSkillPointsTop15 = register_cvar( "bps_skillpoints_cmd_top15", "1" )
  170.     g_iHideCmds = register_cvar( "bps_hide_cmd", "0" )
  171.     g_iEnableWonPointsHour = register_cvar( "bps_enable_win_per_hour", "1" )
  172.     g_iWonPointsHour = register_cvar( "bps_won_points_hour", "5" )
  173.     g_iLostPointsTK = register_cvar( "bps_lost_points_tk", "5" )
  174.     g_iLostPointsSuicide = register_cvar( "bps_lost_points_suicide", "1" )
  175.     g_iWonPointsKill = register_cvar( "bps_won_points_kill", "1" )
  176.     g_iLostPointsDeath = register_cvar( "bps_lost_points_kill", "1" )
  177.     g_iWonPointsHeadshot = register_cvar( "bps_won_points_headshot", "2" )
  178.     g_iLostPointsHeadshot = register_cvar( "bps_lost_points_headshot", "2" )
  179.     g_iWonPointsKnife = register_cvar( "bps_won_points_knife", "3" )
  180.     g_iLostPointsKnife = register_cvar( "bps_lost_points_knife", "3" )
  181.     g_iWonPointsGrenade = register_cvar( "bps_won_points_grenade", "3" )
  182.     g_iLostPointsGrenade = register_cvar( "bps_lost_points_grenade", "3" )
  183.     g_iWonPointsTerrorists = register_cvar( "bps_won_points_ts", "1" )
  184.     g_iWonPointsCounterTerrorists = register_cvar( "bps_won_points_cts", "1" )
  185.     g_iLostPointsTerrorists = register_cvar( "bps_lost_points_ts", "1" )
  186.     g_iLostPointsCounterTerrorists = register_cvar( "bps_lost_points_cts", "1" )
  187.     g_iWonPointsPlanter = register_cvar( "bps_won_points_planter", "1" )
  188.     g_iWonPointsPlanterExplode = register_cvar( "bps_won_points_planter_explode", "2" )
  189.     g_iWonPointsDefuser = register_cvar( "bps_won_points_defuser", "3" )
  190.     g_iWonPoints4k = register_cvar( "bps_won_points_4k", "4" )
  191.     g_iWonPoints5k = register_cvar( "bps_won_points_5k", "5" )
  192.     g_iNegativePoints = register_cvar( "bps_negative_points", "0" )
  193.    
  194.     g_pcvarHost = register_cvar( "bps_sql_host", "", FCVAR_PROTECTED )
  195.     g_pcvaruUser = register_cvar( "bps_sql_user", "", FCVAR_PROTECTED )
  196.     g_pcvarPass = register_cvar( "bps_sql_pass", "", FCVAR_PROTECTED )
  197.     g_pcvarDB = register_cvar( "bps_sql_db", "", FCVAR_PROTECTED )
  198.    
  199.     if( get_pcvar_num( g_iAdsOnChat ) )
  200.     {
  201.         set_task( get_pcvar_float( g_TimeBetweenAds ), "ChatAdvertisements", _, _, _, "b" )
  202.     }
  203. }
  204.  
  205. public SqlInit( )
  206. {
  207.     new szHost[ 32 ]
  208.     new szUser[ 32 ]
  209.     new szPass[ 32 ]
  210.     new szDB[ 32 ]
  211.    
  212.     get_pcvar_string( g_pcvarHost, szHost, charsmax( szHost ) )
  213.     get_pcvar_string( g_pcvaruUser, szUser, charsmax( szUser ) )
  214.     get_pcvar_string( g_pcvarPass, szPass, charsmax( szPass ) )
  215.     get_pcvar_string( g_pcvarDB, szDB, charsmax( szDB ) )
  216.    
  217.     g_SqlTuple = SQL_MakeDbTuple( szHost, szUser, szPass, szDB )
  218.    
  219.     new g_Error[ 512 ]
  220.     new ErrorCode
  221.     new Handle:SqlConnection = SQL_Connect( g_SqlTuple, ErrorCode, g_Error, charsmax( g_Error ) )
  222.    
  223.     if( SqlConnection == Empty_Handle )
  224.     {
  225.         set_fail_state( g_Error )
  226.     }
  227.    
  228.     new Handle:Queries
  229.     Queries = SQL_PrepareQuery( SqlConnection,
  230.     "CREATE TABLE IF NOT EXISTS %s \
  231.     ( authid VARCHAR( 35 ) PRIMARY KEY,\
  232.     nick VARCHAR( 32 ),\
  233.     skillpoints INT( 7 ),\
  234.     level INT( 2 ),\
  235.     kills INT( 7 ),\
  236.     deaths INT( 7 ),\
  237.     headshots INT( 7 ),\
  238.     knife_kills INT( 7 ),\
  239.     knife_deaths INT( 7 ),\
  240.     grenade_kills INT( 7 ),\
  241.     grenade_deaths INT( 7 ),\
  242.     bomb_explosions INT( 7 ),\
  243.     defused_bombs INT( 7 ),\
  244.     own_rounds INT( 7 ) )",
  245.     SQL_TABLE )
  246.    
  247.     if( !SQL_Execute( Queries ) )
  248.     {
  249.         SQL_QueryError( Queries, g_Error, charsmax( g_Error ) )
  250.         set_fail_state( g_Error )
  251.     }
  252.    
  253.     SQL_FreeHandle( Queries )
  254.     SQL_FreeHandle( SqlConnection )
  255.    
  256.     MakeTop15( )
  257. }
  258.  
  259. public plugin_end( )
  260. {
  261.     SQL_FreeHandle( g_SqlTuple )
  262. }
  263.  
  264. public client_authorized( id )
  265. {
  266.     set_task( 4.0, "Delayed_client_authorized", id + CONNECT_TASK ) 
  267. }
  268.  
  269. public Delayed_client_authorized( id )
  270. {   
  271.     id -= CONNECT_TASK
  272.    
  273.     get_user_name( id , g_szAuthID[ id ], charsmax( g_szAuthID[ ] ) )
  274.     get_user_info( id, "name", g_szName[ id ], charsmax( g_szName[ ] ) )
  275.    
  276.     replace_all( g_szName[ id ], charsmax( g_szName[ ] ), "'", "*" )
  277.     replace_all( g_szName[ id ], charsmax( g_szName[ ] ), "^"", "*" )
  278.     replace_all( g_szName[ id ], charsmax( g_szName[ ] ), "`", "*" )
  279.     replace_all( g_szName[ id ], charsmax( g_szName[ ] ), "´", "*" )
  280.    
  281.     g_iPoints[ id ] = 0
  282.     g_iLevels[ id ] = 0
  283.     g_iClasses[ id ] = 0
  284.     g_iCurrentKills[ id ] = 0
  285.    
  286.     g_iKills[ id ] = 0
  287.     g_iDeaths[ id ] = 0
  288.     g_iHeadShots[ id ] = 0
  289.     g_iKnifeKills[ id ] = 0
  290.     g_iKnifeDeaths[ id ] = 0
  291.     g_iGrenadeKills[ id ] = 0
  292.     g_iGrenadeDeaths[ id ] = 0
  293.     g_iBombExplosions[ id ] = 0
  294.     g_iDefusedBombs[ id ] = 0
  295.     g_iWonRounds[ id ] = 0
  296.    
  297.     LoadPoints( id )
  298.    
  299.     if( get_pcvar_num( g_iEnableWonPointsHour ) && get_pcvar_num( g_iWonPointsHour ) )
  300.     {
  301.         set_task( 3600.0, "GiveSkillPointsHour", id, _, _, "b" )
  302.     }
  303. }
  304.  
  305. public client_infochanged( id )
  306. {
  307.     if( is_user_connected( id ) && !task_exists( id + CONNECT_TASK ) )
  308.     {
  309.         new szNewName[ 32 ]
  310.         get_user_info( id, "name", szNewName, charsmax( szNewName ) )
  311.        
  312.         new iLen = strlen( szNewName )
  313.        
  314.         new iPos = iLen - 1
  315.        
  316.         if( szNewName[ iPos ] == '>' )
  317.         {    
  318.             new i
  319.             for( i = 1; i < 7; i++ )
  320.             {    
  321.                 if( szNewName[ iPos - i ] == '<' )
  322.                 {    
  323.                     iLen = iPos - i
  324.                     szNewName[ iLen ] = EOS
  325.                     break
  326.                 }
  327.             }
  328.         }
  329.        
  330.         trim( szNewName )
  331.        
  332.         if( !equal( g_szName[ id ], szNewName ) )  
  333.         {    
  334.             copy( g_szName[ id ], charsmax( g_szName[ ] ), szNewName )
  335.            
  336.             replace_all( g_szName[ id ], charsmax( g_szName[ ] ), "'", "*" )
  337.             replace_all( g_szName[ id ], charsmax( g_szName[ ] ), "^"", "*" )
  338.             replace_all( g_szName[ id ], charsmax( g_szName[ ] ), "`", "*" )
  339.             replace_all( g_szName[ id ], charsmax( g_szName[ ] ), "´", "*" )
  340.         }
  341.     }
  342. }
  343.  
  344. public client_disconnect( id )
  345. {   
  346.     if( task_exists( id ) )
  347.     {
  348.         remove_task( id )
  349.     }
  350.    
  351.     if( task_exists( id + CONNECT_TASK ) )
  352.     {
  353.         remove_task( id + CONNECT_TASK )
  354.     }
  355.    
  356.     CheckLevelAndSave( id )
  357. }
  358.  
  359. public ClCmd_Say( id )
  360. {   
  361.     new szCmd[ 12 ]
  362.     read_argv( 1, szCmd, charsmax( szCmd ) )
  363.    
  364.     if( equali( szCmd[ 1 ], "myskill" ) )
  365.     {
  366.         GetSkillPoints( id )
  367.     }
  368.    
  369.     else if( equali( szCmd[ 1 ], "restartskill" ) )
  370.     {
  371.         RestartSkillPoints( id )
  372.     }
  373.    
  374.     else if( equali( szCmd[ 1 ], "rankskill" ) )
  375.     {
  376.         SkillRank( id )
  377.     }
  378.    
  379.     else if( equali( szCmd[ 1 ], "topskill" ) )
  380.     {
  381.         TopSkill( id )
  382.     }
  383.    
  384.     new chat[192], none[2][32], message[192], message2[192], name[192]
  385.     read_argv(1, chat, sizeof(chat) -1)
  386.     formatex(none[0], sizeof(none) -1, ""), formatex(none[1], sizeof(none) -1, " ")
  387.    
  388.     if(!equali(chat, none[0]) && !equali(chat, none[1]))
  389.     {
  390.         get_user_name(id, name, sizeof(name) -1)
  391.         switch(cs_get_user_team(id))
  392.         {
  393.             case CS_TEAM_CT: {
  394.                 if(!is_user_alive(id))
  395.                     formatex(message, sizeof(message) -1, "!g[%s]!n *DEAD* !t%s !n: %s", CLASSES[ g_iLevels[ id ] ], name, chat)
  396.                 else
  397.                     formatex(message, sizeof(message) -1, "!g[%s]!n !t%s !n: %s", CLASSES[ g_iLevels[ id ] ], name, chat)
  398.                 new iPlayers[32], iNum, iPid
  399.                 get_players(iPlayers, iNum)
  400.                 for(new i; i < iNum; i++)
  401.                 {
  402.                     iPid = iPlayers[i]
  403.                     if(cs_get_user_team(iPid) != CS_TEAM_CT)
  404.                         continue;
  405.                    
  406.                     ClientPrintColor(iPid,  message)
  407.                 }
  408.             }
  409.             case CS_TEAM_T: {
  410.                 if(!is_user_alive(id))
  411.                     formatex(message2, sizeof(message2) -1, "!g[%s]!n *DEAD* !t%s !n: %s", CLASSES[ g_iLevels[ id ] ], name, chat)
  412.                 else
  413.                     formatex(message2, sizeof(message2) -1, "!g[%s] !t%s !n: %s", CLASSES[ g_iLevels[ id ] ], name, chat)
  414.                 new iPlayers[32], iNum, iPid
  415.                 get_players(iPlayers, iNum)
  416.                 for(new i; i< iNum; i++)
  417.                 {
  418.                     iPid = iPlayers[i]
  419.                     if(cs_get_user_team(iPid) != CS_TEAM_T)
  420.                         continue
  421.                    
  422.                     ClientPrintColor(iPid, message2)
  423.                 }
  424.             }
  425.         }
  426.     }
  427.     return PLUGIN_HANDLED_MAIN;
  428. }
  429.  
  430. public ClCmd_Say_team(id){
  431.     new chat[192], none[2][32], message[192], message2[192], name[192]
  432.     read_argv(1, chat, sizeof(chat) -1)
  433.     formatex(none[0], sizeof(none) -1, ""), formatex(none[1], sizeof(none) -1, " ")
  434.    
  435.     if(!equali(chat, none[0]) && !equali(chat, none[1]))
  436.     {
  437.         get_user_name(id, name, sizeof(name) -1)
  438.         switch(cs_get_user_team(id))
  439.         {
  440.             case CS_TEAM_CT: {
  441.                 if(!is_user_alive(id))
  442.                     formatex(message, sizeof(message) -1, "!g[%s]!n (Counter-Terrorists) *DEAD* !t%s !n: %s", CLASSES[ g_iLevels[ id ] ], name, chat)
  443.                 else
  444.                     formatex(message, sizeof(message) -1, "!g[%s]!n (Counter-Terrorists) !t%s !n: %s", CLASSES[ g_iLevels[ id ] ], name, chat)
  445.                 new iPlayers[32], iNum, iPid
  446.                 get_players(iPlayers, iNum)
  447.                 for(new i; i < iNum; i++)
  448.                 {
  449.                     iPid = iPlayers[i]
  450.                     if(cs_get_user_team(iPid) != CS_TEAM_CT)
  451.                         continue;
  452.                    
  453.                     ClientPrintColor(iPid,  message)
  454.                 }
  455.             }
  456.             case CS_TEAM_T: {
  457.                 if(!is_user_alive(id))
  458.                     formatex(message2, sizeof(message2) -1, "!g[%s]!n (Terrorists) *DEAD* !t%s !n: %s", CLASSES[ g_iLevels[ id ] ], name, chat)
  459.                 else
  460.                     formatex(message2, sizeof(message2) -1, "!g[%s]!n (Terrorists) !t%s !n: %s", CLASSES[ g_iLevels[ id ] ], name, chat)
  461.                 new iPlayers[32], iNum, iPid
  462.                 get_players(iPlayers, iNum)
  463.                 for(new i; i< iNum; i++)
  464.                 {
  465.                     iPid = iPlayers[i]
  466.                     if(cs_get_user_team(iPid) != CS_TEAM_T)
  467.                         continue
  468.                    
  469.                     ClientPrintColor(iPid, message2)
  470.                 }
  471.             }
  472.         }
  473.         return PLUGIN_HANDLED_MAIN;
  474.     }
  475.     return PLUGIN_CONTINUE;  
  476. }
  477.  
  478. public GiveSkillPointsHour( id )
  479. {
  480.     g_iPoints[ id ] += get_pcvar_num( g_iWonPointsHour )
  481.    
  482.     if( get_pcvar_num( g_iEnableAnnounceOnChat ) )
  483.     {
  484.         ClientPrintColor( id, "!g%s!n You earned!t %i!n point%s for playing more one hour", PREFIX, get_pcvar_num( g_iWonPointsHour ), get_pcvar_num( g_iWonPointsHour ) > 1 ? "s" : "" )
  485.     }
  486. }
  487.  
  488. public client_death( iKiller, iVictim, iWpnIndex, iHitPlace, iTK )
  489. {   
  490.     if( !IsPlayer( iKiller ) || !IsPlayer( iVictim ) )
  491.     {
  492.         return PLUGIN_CONTINUE
  493.     }
  494.    
  495.     if( iTK )
  496.     {
  497.         g_iPoints[ iKiller ] -= get_pcvar_num( g_iLostPointsTK )
  498.        
  499.         if( get_pcvar_num( g_iEnableAnnounceOnChat ) && get_pcvar_num( g_iLostPointsTK ) )
  500.         {
  501.             ClientPrintColor( iKiller, "!g%s!n You have lost!t %i!n point%s by killing a teammate", PREFIX, get_pcvar_num( g_iLostPointsTK ), get_pcvar_num( g_iLostPointsTK ) > 1 ? "s" : ""  )
  502.         }
  503.        
  504.         return PLUGIN_CONTINUE
  505.     }
  506.    
  507.     if( iKiller == iVictim )
  508.     {
  509.         g_iPoints[ iKiller ] -= get_pcvar_num( g_iLostPointsSuicide )
  510.        
  511.         if( get_pcvar_num( g_iEnableAnnounceOnChat ) && get_pcvar_num( g_iLostPointsSuicide ) )
  512.         {
  513.             ClientPrintColor( iKiller, "!g%s!n You have lost!t %i!n point%s for committing suicide", PREFIX, get_pcvar_num( g_iLostPointsSuicide ), get_pcvar_num( g_iLostPointsSuicide ) > 1 ? "s" : ""  )
  514.         }
  515.        
  516.         g_iDeaths[ iKiller ]++
  517.        
  518.         return PLUGIN_CONTINUE
  519.     }
  520.    
  521.     g_iCurrentKills[ iKiller ]++
  522.     g_iKills[ iKiller ]++
  523.    
  524.     g_iDeaths[ iVictim ]++
  525.    
  526.     if( iWpnIndex == CSW_HEGRENADE )
  527.     {
  528.         g_iPoints[ iKiller ] += get_pcvar_num( g_iWonPointsGrenade )
  529.         g_iGrenadeKills[ iKiller]++
  530.        
  531.         if( get_pcvar_num( g_iEnableAnnounceOnChat ) && get_pcvar_num( g_iWonPointsGrenade ) )
  532.         {
  533.             ClientPrintColor( iKiller, "!g%s!n You earned!t %i!n point%s by killing %s with a grenade", PREFIX, get_pcvar_num( g_iWonPointsGrenade ), get_pcvar_num( g_iWonPointsGrenade ) > 1 ? "s" : "" ,g_szName[ iVictim ] )
  534.         }
  535.        
  536.         g_iPoints[ iVictim ] -= get_pcvar_num( g_iLostPointsGrenade )
  537.         g_iGrenadeDeaths[ iVictim ]++
  538.        
  539.         if( get_pcvar_num( g_iEnableAnnounceOnChat ) && get_pcvar_num( g_iLostPointsGrenade ) )
  540.         {
  541.             ClientPrintColor( iVictim, "!g%s!n You have lost!t %i!n point%s for dying with a grenade", PREFIX, get_pcvar_num( g_iLostPointsGrenade ), get_pcvar_num( g_iLostPointsGrenade ) > 1 ? "s" : "" )
  542.         }
  543.        
  544.         return PLUGIN_CONTINUE
  545.     }
  546.    
  547.     if( iWpnIndex == CSW_KNIFE )
  548.     {
  549.         g_iPoints[ iKiller ] += get_pcvar_num( g_iWonPointsKnife )
  550.         g_iKnifeKills[ iKiller ]++
  551.        
  552.         if( get_pcvar_num( g_iEnableAnnounceOnChat ) && get_pcvar_num( g_iWonPointsKnife ) )
  553.         {
  554.             ClientPrintColor( iKiller, "!g%s!n You earned!t %i!n point%s by killing %s with knife", PREFIX, get_pcvar_num( g_iWonPointsKnife ), get_pcvar_num( g_iWonPointsKnife ) > 1 ? "s" : "" ,g_szName[ iVictim ] )
  555.         }
  556.        
  557.         g_iPoints[ iVictim ] -= get_pcvar_num( g_iLostPointsKnife )
  558.         g_iKnifeDeaths[ iVictim ]++
  559.        
  560.         if( get_pcvar_num( g_iEnableAnnounceOnChat ) && get_pcvar_num( g_iLostPointsKnife ) )
  561.         {
  562.             ClientPrintColor( iVictim, "!g%s!n You have lost!t %i!n point%s for dying with knife", PREFIX, get_pcvar_num( g_iLostPointsKnife ), get_pcvar_num( g_iLostPointsKnife ) > 1 ? "s" : "" )
  563.         }
  564.        
  565.         return PLUGIN_CONTINUE
  566.     }
  567.    
  568.     if( iHitPlace == HIT_HEAD )
  569.     {
  570.         g_iPoints[ iKiller ] += get_pcvar_num( g_iWonPointsHeadshot )
  571.         g_iHeadShots[ iKiller ]++
  572.        
  573.         if( get_pcvar_num( g_iEnableAnnounceOnChat ) && get_pcvar_num( g_iWonPointsHeadshot ) )
  574.         {
  575.             ClientPrintColor( iKiller, "!g%s!n You earned!t %i!n point%s by killing %s with a headshot", PREFIX, get_pcvar_num( g_iWonPointsHeadshot ), get_pcvar_num( g_iWonPointsHeadshot ) > 1 ? "s" : "" ,g_szName[ iVictim ] )
  576.         }
  577.        
  578.         g_iPoints[ iVictim ] -= get_pcvar_num( g_iLostPointsHeadshot )
  579.        
  580.         if( get_pcvar_num( g_iEnableAnnounceOnChat ) && get_pcvar_num( g_iLostPointsHeadshot ) )
  581.         {
  582.             ClientPrintColor( iVictim, "!g%s!n You have lost!t %i!n point%s for dying with a headshot", PREFIX, get_pcvar_num( g_iLostPointsHeadshot ), get_pcvar_num( g_iLostPointsHeadshot ) > 1 ? "s" : "" )
  583.         }
  584.        
  585.         return PLUGIN_CONTINUE
  586.     }
  587.    
  588.     g_iPoints[ iKiller ] += get_pcvar_num( g_iWonPointsKill )
  589.    
  590.     if( get_pcvar_num( g_iEnableAnnounceOnChat ) && get_pcvar_num( g_iWonPointsKill ) )
  591.     {
  592.         ClientPrintColor( iKiller, "!g%s!n You earned!t %i!n point%s by killing %s", PREFIX, get_pcvar_num( g_iWonPointsKill ), get_pcvar_num( g_iWonPointsKill ) > 1 ? "s" : "", g_szName[ iVictim ] )
  593.     }
  594.    
  595.     g_iPoints[ iVictim ] -= get_pcvar_num( g_iLostPointsDeath )
  596.    
  597.     if( get_pcvar_num( g_iEnableAnnounceOnChat ) && get_pcvar_num( g_iLostPointsDeath ) )
  598.     {
  599.         ClientPrintColor( iVictim, "!g%s!n You have lost!t %i!n point%s for dying", PREFIX, get_pcvar_num( g_iLostPointsDeath ), get_pcvar_num( g_iLostPointsDeath ) > 1 ? "s" : "" )
  600.     }
  601.    
  602.     return PLUGIN_CONTINUE
  603. }
  604.  
  605. public TerroristsWin( )
  606. {
  607.     if( g_bRoundEnded )
  608.     {
  609.         return PLUGIN_CONTINUE
  610.     }
  611.    
  612.     new Players[ MAX_PLAYERS ]
  613.     new iNum
  614.     new i
  615.    
  616.     get_players( Players, iNum, "ch" )
  617.    
  618.     for( --iNum; iNum >= 0; iNum-- )
  619.     {
  620.         i = Players[ iNum ]
  621.        
  622.         switch( cs_get_user_team( i ) )
  623.         {
  624.             case( CS_TEAM_T ):
  625.             {
  626.                 if( get_pcvar_num( g_iWonPointsTerrorists ) )
  627.                 {
  628.                     g_iPoints[ i ] += get_pcvar_num( g_iWonPointsTerrorists )
  629.                     g_iWonRounds[ i ]++
  630.                    
  631.                     if( get_pcvar_num( g_iEnableAnnounceOnChat ) )
  632.                     {
  633.                         ClientPrintColor( i, "!g%s!n Your team!t (T)!n have won!t %i!n point%s for winning the round", PREFIX, get_pcvar_num( g_iWonPointsTerrorists ), get_pcvar_num( g_iWonPointsTerrorists ) > 1 ? "s" : "" )
  634.                     }
  635.                 }
  636.             }
  637.            
  638.             case( CS_TEAM_CT ):
  639.             {
  640.                 if( get_pcvar_num( g_iLostPointsCounterTerrorists ) )
  641.                 {
  642.                     g_iPoints[ i ] -= get_pcvar_num( g_iLostPointsCounterTerrorists )
  643.                    
  644.                     if( get_pcvar_num( g_iEnableAnnounceOnChat ) )
  645.                     {
  646.                         ClientPrintColor( i, "!g%s!n Your team!t (CT)!n have lost!t %i!n point%s for losing the round", PREFIX, get_pcvar_num( g_iLostPointsCounterTerrorists ), get_pcvar_num( g_iLostPointsCounterTerrorists ) > 1 ? "s" : "" )
  647.                     }
  648.                 }
  649.             }
  650.         }
  651.     }
  652.    
  653.     g_bRoundEnded = true
  654.    
  655.     return PLUGIN_CONTINUE
  656. }
  657.  
  658. public CounterTerroristsWin( )
  659. {
  660.     if( g_bRoundEnded )
  661.     {
  662.         return PLUGIN_CONTINUE
  663.     }
  664.    
  665.     new Players[ MAX_PLAYERS ]
  666.     new iNum
  667.     new i
  668.    
  669.     get_players( Players, iNum, "ch" )
  670.    
  671.     for( --iNum; iNum >= 0; iNum-- )
  672.     {
  673.         i = Players[ iNum ]
  674.        
  675.         switch( cs_get_user_team( i ) )
  676.         {
  677.             case( CS_TEAM_T ):
  678.             {
  679.                 if( get_pcvar_num( g_iLostPointsTerrorists ) )
  680.                 {
  681.                     g_iPoints[ i ] -= get_pcvar_num( g_iLostPointsTerrorists )
  682.                    
  683.                     if( get_pcvar_num( g_iEnableAnnounceOnChat ) )
  684.                     {
  685.                         ClientPrintColor( i, "!g%s!n Your team!t (T)!n have lost!t %i!n point%s for losing the round", PREFIX, get_pcvar_num( g_iLostPointsTerrorists ), get_pcvar_num( g_iLostPointsTerrorists ) > 1 ? "s" : "" )
  686.                     }
  687.                 }
  688.             }
  689.            
  690.             case( CS_TEAM_CT ):
  691.             {
  692.                 if( get_pcvar_num( g_iWonPointsCounterTerrorists ) )
  693.                 {
  694.                     g_iPoints[ i ] += get_pcvar_num( g_iWonPointsCounterTerrorists )
  695.                     g_iWonRounds[ i ]++
  696.                    
  697.                     if( get_pcvar_num( g_iEnableAnnounceOnChat ) )
  698.                     {
  699.                         ClientPrintColor( i, "!g%s!n Your team!t (CT)!n have won!t %i!n point%s for winning the round", PREFIX, get_pcvar_num( g_iWonPointsCounterTerrorists ), get_pcvar_num( g_iWonPointsCounterTerrorists ) > 1 ? "s" : "" )
  700.                     }
  701.                 }
  702.             }
  703.         }
  704.     }
  705.    
  706.     g_bRoundEnded = true
  707.    
  708.     return PLUGIN_CONTINUE
  709. }
  710.  
  711. public bomb_planted( planter )
  712. {
  713.     if( get_pcvar_num( g_iWonPointsPlanter ) )
  714.     {
  715.         g_iPoints[ planter ] += get_pcvar_num( g_iWonPointsPlanter )
  716.        
  717.         if( get_pcvar_num( g_iEnableAnnounceOnChat ) )
  718.         {
  719.             ClientPrintColor( planter, "!g%s!n You earned!t %i!n point%s for planting the bomb", PREFIX, get_pcvar_num( g_iWonPointsPlanter ), get_pcvar_num( g_iWonPointsPlanter ) > 1 ? "s" : "" )
  720.         }
  721.     }
  722. }
  723.  
  724. public bomb_explode( planter, defuser )
  725. {
  726.     if( get_pcvar_num( g_iWonPointsPlanterExplode ) )
  727.     {
  728.         g_iPoints[ planter ] += get_pcvar_num( g_iWonPointsPlanterExplode )
  729.         g_iBombExplosions[ planter ]++
  730.        
  731.         if( get_pcvar_num( g_iEnableAnnounceOnChat ) )
  732.         {
  733.             ClientPrintColor( planter, "!g%s!n You earned!t %i!n point%s with the bomb explosion", PREFIX, get_pcvar_num( g_iWonPointsPlanterExplode ), get_pcvar_num( g_iWonPointsPlanterExplode ) > 1 ? "s" : "" )
  734.         }
  735.     }
  736. }
  737.  
  738. public bomb_defused( defuser )
  739. {
  740.     if( get_pcvar_num( g_iWonPointsDefuser ) )
  741.     {
  742.         g_iPoints[ defuser ] += get_pcvar_num( g_iWonPointsDefuser )
  743.         g_iDefusedBombs[ defuser ]++
  744.        
  745.         if( get_pcvar_num( g_iEnableAnnounceOnChat ) )
  746.         {
  747.             ClientPrintColor( defuser, "!g%s!n You earned!t %i!n point%s for disarming the bomb", PREFIX, get_pcvar_num( g_iWonPointsDefuser ), get_pcvar_num( g_iWonPointsDefuser ) > 1 ? "s" : "" )
  748.         }
  749.     }
  750. }
  751.  
  752. public EventNewRound( )
  753. {
  754.     g_bRoundEnded = false
  755.    
  756.     MakeTop15( )
  757. }
  758.  
  759. public EventRoundEnd( )
  760. {
  761.     set_task( 0.5, "SavePointsAtRoundEnd" )
  762. }
  763.  
  764. public SavePointsAtRoundEnd( )
  765. {
  766.     new Players[ MAX_PLAYERS ]
  767.     new iNum
  768.     new i
  769.    
  770.     get_players( Players, iNum, "ch" )
  771.    
  772.     for( --iNum; iNum >= 0; iNum-- )
  773.     {
  774.         i = Players[ iNum ]
  775.        
  776.         if( g_iCurrentKills[ i ] == 4 && get_pcvar_num( g_iWonPoints4k ) )
  777.         {
  778.             g_iPoints[ i ] += get_pcvar_num( g_iWonPoints4k )
  779.            
  780.             if( get_pcvar_num( g_iEnableAnnounceOnChat ) )
  781.             {
  782.                 ClientPrintColor( i, "!g%s!n You earned!t %i!n point%s for killing 4 in a round", PREFIX, get_pcvar_num( g_iWonPoints4k ), get_pcvar_num( g_iWonPoints4k ) > 1 ? "s" : "" )
  783.             }
  784.         }
  785.        
  786.         if( g_iCurrentKills[ i ] >= 5 && get_pcvar_num( g_iWonPoints5k ) )
  787.         {
  788.             g_iPoints[ i ] += get_pcvar_num( g_iWonPoints5k )
  789.            
  790.             if( get_pcvar_num( g_iEnableAnnounceOnChat ) )
  791.             {
  792.                 ClientPrintColor( i, "!g%s!n You earned!t %i!n point%s for killing 5 in a round", PREFIX, get_pcvar_num( g_iWonPoints5k ), get_pcvar_num( g_iWonPoints5k ) > 1 ? "s" : "" )
  793.             }
  794.         }
  795.        
  796.         CheckLevelAndSave( i )
  797.     }
  798. }
  799.  
  800. public CheckLevelAndSave( id )
  801. {
  802.     if( !get_pcvar_num( g_iNegativePoints) )
  803.     {
  804.         if( g_iPoints[ id ] < 0 )
  805.         {
  806.             g_iPoints[ id ] = 0
  807.         }
  808.        
  809.         if( g_iLevels[ id ] < 0 )
  810.         {
  811.             g_iLevels[ id ] = 0
  812.         }
  813.     }
  814.    
  815.     while( g_iPoints[ id ] >= LEVELS[ g_iLevels[ id ] ] )
  816.     {
  817.         g_iLevels[ id ] += 1
  818.         g_iClasses[ id ] += 1
  819.        
  820.         if( get_pcvar_num( g_iEnableAnnounceOnChat ) )
  821.         {
  822.             ClientPrintColor( 0, "!g%s!n %s increased one level! Level:!t %s!n Total points:!t %d", PREFIX, g_szName[ id ], CLASSES[ g_iLevels[ id ] ], g_iPoints[ id ] )
  823.         }
  824.     }
  825.    
  826.     new szTemp[ 512 ]
  827.     formatex( szTemp, charsmax( szTemp ),
  828.     "UPDATE %s SET nick = '%s', skillpoints = '%i', level = '%i',\
  829.     kills = '%i', deaths = '%i', headshots = '%i', knife_kills = '%i', knife_deaths = '%i', grenade_kills = '%i', grenade_deaths = '%i', bomb_explosions = '%i', defused_bombs = '%i', own_rounds = '%i'\
  830.     WHERE authid = '%s'",
  831.     SQL_TABLE, g_szName[ id ], g_iPoints[ id ], g_iLevels[ id ],
  832.     g_iKills[ id ], g_iDeaths[ id ], g_iHeadShots[ id ], g_iKnifeKills[ id ], g_iKnifeDeaths[ id ], g_iGrenadeKills[ id ], g_iGrenadeDeaths[ id ], g_iBombExplosions[ id ], g_iDefusedBombs[ id ], g_iWonRounds[ id ],
  833.     g_szAuthID[ id ] )
  834.    
  835.     SQL_ThreadQuery( g_SqlTuple, "IgnoreHandle", szTemp )
  836.    
  837.     if( g_iPoints[ id ] >= MAX_PONTUATION )
  838.     {      
  839.         if( get_pcvar_num( g_iEnableAnnounceOnChat ) )
  840.         {
  841.             ClientPrintColor( id, "!g%s!n You have reached the maximum SkillPoints! Your SkillPoints and level will start again", PREFIX )
  842.         }
  843.        
  844.         g_iPoints[ id ] = 0
  845.         g_iLevels[ id ] = 0
  846.         g_iClasses[ id ] = 0
  847.        
  848.         g_iKills[ id ] = 0
  849.         g_iDeaths[ id ] = 0
  850.         g_iHeadShots[ id ] = 0
  851.         g_iKnifeKills[ id ] = 0
  852.         g_iKnifeDeaths[ id ] = 0
  853.         g_iGrenadeKills[ id ] = 0
  854.         g_iGrenadeDeaths[ id ] = 0
  855.         g_iBombExplosions[ id ] = 0
  856.         g_iDefusedBombs[ id ] = 0
  857.         g_iWonRounds[ id ] = 0
  858.        
  859.         CheckLevelAndSave( id )
  860.     }
  861. }
  862.  
  863. public LoadPoints( id )
  864. {
  865.     new Data[ 1 ]
  866.     Data[ 0 ] = id
  867.    
  868.     new szTemp[ 512 ]
  869.     format( szTemp, charsmax( szTemp ),
  870.     "SELECT skillpoints, level , kills, deaths, headshots, knife_kills, knife_deaths, grenade_kills, grenade_deaths, bomb_explosions, defused_bombs, own_rounds FROM %s WHERE authid = '%s'",
  871.     SQL_TABLE, g_szAuthID[ id ] )
  872.    
  873.     SQL_ThreadQuery( g_SqlTuple, "LoadPoints_QueryHandler", szTemp, Data, 1 )
  874. }
  875.  
  876. public LoadPoints_QueryHandler( FailState, Handle:Query, Error[ ], Errcode, Data[ ], DataSize )
  877. {
  878.     new id
  879.     id = Data[ 0 ]
  880.    
  881.     if( !SQL_IsFail( FailState, Errcode, Error ) )
  882.     {
  883.         if( SQL_NumResults( Query ) < 1 )
  884.         {
  885.             new szTemp[ 512 ]
  886.             format( szTemp, charsmax( szTemp ),
  887.             "INSERT INTO %s\
  888.             ( authid, nick, skillpoints, level, kills, deaths, headshots, knife_kills, knife_deaths, grenade_kills, grenade_deaths, bomb_explosions, defused_bombs, own_rounds )\
  889.             VALUES( '%s', '%s', '%i', '%i', '%i', '%i', '%i', '%i', '%i', '%i', '%i', '%i', '%i', '%i' )",
  890.             SQL_TABLE,
  891.             g_szAuthID[ id ],
  892.             g_szName[ id ],
  893.             g_iPoints[ id ],
  894.             g_iLevels[ id ],
  895.            
  896.             g_iKills[ id ],
  897.             g_iDeaths[ id ],
  898.             g_iHeadShots[ id ],
  899.             g_iKnifeKills[ id ],
  900.             g_iKnifeDeaths[ id ],
  901.             g_iGrenadeKills[ id ],
  902.             g_iGrenadeDeaths[ id ],
  903.             g_iBombExplosions[ id ],
  904.             g_iDefusedBombs[ id ],
  905.             g_iWonRounds[ id ] )
  906.            
  907.             SQL_ThreadQuery( g_SqlTuple, "IgnoreHandle", szTemp )
  908.         }
  909.        
  910.         else
  911.         {
  912.             g_iPoints[ id ] = SQL_ReadResult( Query, 0 )
  913.             g_iLevels[ id ] = SQL_ReadResult( Query, 1 )
  914.            
  915.             g_iKills[ id ] = SQL_ReadResult( Query, 2 )
  916.             g_iDeaths[ id ] = SQL_ReadResult( Query, 3 )
  917.             g_iHeadShots[ id ] = SQL_ReadResult( Query, 4 )
  918.             g_iKnifeKills[ id ] = SQL_ReadResult( Query, 5 )
  919.             g_iKnifeDeaths[ id ] = SQL_ReadResult( Query, 6 )
  920.             g_iGrenadeKills[ id ] = SQL_ReadResult( Query, 7 )
  921.             g_iGrenadeDeaths[ id ] = SQL_ReadResult( Query, 8 )
  922.             g_iBombExplosions[ id ] = SQL_ReadResult( Query, 9 )
  923.             g_iDefusedBombs[ id ] = SQL_ReadResult( Query, 10 )
  924.             g_iWonRounds[ id ] = SQL_ReadResult( Query, 11 )
  925.         }
  926.     }
  927. }
  928.  
  929. public IgnoreHandle( FailState, Handle:Query, Error[ ], Errcode, Data[ ], DataSize )
  930. {
  931.     SQL_FreeHandle( Query )
  932. }
  933.  
  934. public SkillRank( id )
  935. {
  936.     if( !get_pcvar_num( g_iEnableSkillPointsCmdRank ) )
  937.     {
  938.         ClientPrintColor( id, "!g%s!n Command disabled", PREFIX )
  939.     }
  940.    
  941.     else
  942.     {      
  943.         new Data[ 1 ]
  944.         Data[ 0 ] = id
  945.        
  946.         new szTemp[ 512 ]
  947.         format( szTemp, charsmax( szTemp ), "SELECT COUNT(*) FROM %s WHERE skillpoints >= %i", SQL_TABLE, g_iPoints[ id ] )
  948.        
  949.         SQL_ThreadQuery( g_SqlTuple, "SkillRank_QueryHandler", szTemp, Data, 1 )
  950.     }
  951.    
  952.     return ( get_pcvar_num( g_iHideCmds ) == 0 ) ? PLUGIN_CONTINUE : PLUGIN_HANDLED_MAIN
  953. }
  954.  
  955. public SkillRank_QueryHandler( FailState, Handle:Query, Error[ ], Errcode, Data[ ], DataSize )
  956. {
  957.     if( !SQL_IsFail( FailState, Errcode, Error ) )
  958.     {
  959.         new id
  960.         id = Data[ 0 ]
  961.        
  962.         g_iRank[ id ] = SQL_ReadResult( Query, 0 )
  963.        
  964.         if( g_iRank[ id ] == 0 )
  965.         {
  966.             g_iRank[ id ] = 1
  967.         }
  968.        
  969.         TotalRows( id )
  970.     }
  971. }
  972.  
  973. public TotalRows( id )
  974. {
  975.     new Data[ 1 ]
  976.     Data[ 0 ] = id
  977.    
  978.     new szTemp[ 128 ]
  979.     format( szTemp, charsmax( szTemp ), "SELECT COUNT(*) FROM %s", SQL_TABLE )
  980.    
  981.     SQL_ThreadQuery( g_SqlTuple, "TotalRows_QueryHandler", szTemp, Data, 1 )
  982. }
  983.  
  984. public TotalRows_QueryHandler( FailState, Handle:Query, Error[ ], Errcode, Data[ ], DataSize )
  985. {
  986.     if( !SQL_IsFail( FailState, Errcode, Error ) )
  987.     {
  988.         new id
  989.         id = Data[ 0 ]
  990.        
  991.         g_iCount = SQL_ReadResult( Query, 0 )
  992.        
  993.         ClientPrintColor( id, "!g%s!n Your rank is!t %i!n of!t %i!n players with!t %i!n points ", PREFIX, g_iRank[ id ], g_iCount, g_iPoints[ id ] )
  994.     }
  995. }
  996.  
  997. public TopSkill( id )
  998. {
  999.     if( !get_pcvar_num( g_iEnableSkillPointsTop15 ) )
  1000.     {
  1001.         ClientPrintColor( id, "!g%s!n Command disabled", PREFIX )
  1002.     }
  1003.    
  1004.     else
  1005.     {
  1006.         show_motd( id, g_szMotd, "Top SkillPointers" )
  1007.     }
  1008.    
  1009.     return ( get_pcvar_num( g_iHideCmds ) == 0 ) ? PLUGIN_CONTINUE : PLUGIN_HANDLED_MAIN
  1010. }
  1011.  
  1012. public MakeTop15( )
  1013. {   
  1014.     new szQuery[ 512 ]
  1015.     formatex( szQuery, charsmax( szQuery ),
  1016.     "SELECT nick, skillpoints, kills, deaths, headshots, knife_kills, grenade_kills, bomb_explosions, defused_bombs FROM %s ORDER BY skillpoints DESC LIMIT 10",
  1017.     SQL_TABLE )
  1018.    
  1019.     SQL_ThreadQuery( g_SqlTuple, "MakeTop15_QueryHandler", szQuery )
  1020. }
  1021.  
  1022. public MakeTop15_QueryHandler( FailState, Handle:Query, Error[ ], Errcode, Data[ ], DataSize )
  1023. {
  1024.     if( !SQL_IsFail( FailState, Errcode, Error ) )
  1025.     {
  1026.         new szName[ 22 ]
  1027.        
  1028.         new iPoints
  1029.         new iKills
  1030.         new iDeaths
  1031.         new iHS
  1032.         new iKnifeKills
  1033.         new iGrenadeKills
  1034.         new iBombExplosions
  1035.         new iDefusedBombs   
  1036.        
  1037.         new iLen
  1038.         iLen = formatex( g_szMotd, charsmax( g_szMotd ),
  1039.         "<body bgcolor=#A4BED6>\
  1040.         <table width=100%% cellpadding=2 cellspacing=0 border=0>\
  1041.         <tr align=center bgcolor=#52697B>\
  1042.         <th width=4%%>#\
  1043.         <th width=30%% align=left>Player\
  1044.         <th width=8%%>Kills\
  1045.         <th width=8%%>Deaths\
  1046.         <th width=8%%>HS\
  1047.         <th width=8%%>Knife\
  1048.         <th width=8%%>Grenade\
  1049.         <th width=8%%>Bombs\
  1050.         <th width=8%%>Defuses\
  1051.         <th width=10%>SkillPoints" )
  1052.        
  1053.         new i = 1
  1054.         while( SQL_MoreResults( Query ) )
  1055.         {
  1056.             SQL_ReadResult( Query, 0, szName, charsmax( szName ) )
  1057.            
  1058.             iPoints = SQL_ReadResult( Query, 1 )
  1059.             iKills = SQL_ReadResult( Query, 2 )
  1060.             iDeaths = SQL_ReadResult( Query, 3 )
  1061.             iHS = SQL_ReadResult( Query, 4 )
  1062.             iKnifeKills = SQL_ReadResult( Query, 5 )
  1063.             iGrenadeKills = SQL_ReadResult( Query, 6 )
  1064.             iBombExplosions = SQL_ReadResult( Query, 7 )
  1065.             iDefusedBombs = SQL_ReadResult( Query, 8 )
  1066.            
  1067.             replace_all( szName, charsmax( szName ), "<", "[" )
  1068.             replace_all( szName, charsmax( szName ), ">", "]" )
  1069.            
  1070.             iLen += formatex( g_szMotd[ iLen ], charsmax( g_szMotd ) - iLen, "<tr align=center>" )
  1071.             iLen += formatex( g_szMotd[ iLen ], charsmax( g_szMotd ) - iLen, "<td>%i", i )
  1072.             iLen += formatex( g_szMotd[ iLen ], charsmax( g_szMotd ) - iLen, "<td align=left>%s", szName )
  1073.             iLen += formatex( g_szMotd[ iLen ], charsmax( g_szMotd ) - iLen, "<td>%i", iKills )
  1074.             iLen += formatex( g_szMotd[ iLen ], charsmax( g_szMotd ) - iLen, "<td>%i", iDeaths )
  1075.             iLen += formatex( g_szMotd[ iLen ], charsmax( g_szMotd ) - iLen, "<td>%i", iHS )
  1076.             iLen += formatex( g_szMotd[ iLen ], charsmax( g_szMotd ) - iLen, "<td>%i", iKnifeKills )
  1077.             iLen += formatex( g_szMotd[ iLen ], charsmax( g_szMotd ) - iLen, "<td>%i", iGrenadeKills )
  1078.             iLen += formatex( g_szMotd[ iLen ], charsmax( g_szMotd ) - iLen, "<td>%i", iBombExplosions )
  1079.             iLen += formatex( g_szMotd[ iLen ], charsmax( g_szMotd ) - iLen, "<td>%i", iDefusedBombs )
  1080.             iLen += formatex( g_szMotd[ iLen ], charsmax( g_szMotd ) - iLen, "<td>%i", iPoints )
  1081.            
  1082.             i++
  1083.            
  1084.             SQL_NextRow( Query )
  1085.         }
  1086.        
  1087.         iLen += formatex( g_szMotd[ iLen ], charsmax( g_szMotd ) - iLen, "</table></body>" )
  1088.     }
  1089. }
  1090.  
  1091. SQL_IsFail( FailState, Errcode, Error[ ] )
  1092. {
  1093.     if( FailState == TQUERY_CONNECT_FAILED )
  1094.     {
  1095.         log_amx( "[Error] Could not connect to SQL database: %s", Error )
  1096.         return true
  1097.     }
  1098.    
  1099.     if( FailState == TQUERY_QUERY_FAILED )
  1100.     {
  1101.         log_amx( "[Error] Query failed: %s", Error )
  1102.         return true
  1103.     }
  1104.    
  1105.     if( Errcode )
  1106.     {
  1107.         log_amx( "[Error] Error on query: %s", Error )
  1108.         return true
  1109.     }
  1110.    
  1111.     return false
  1112. }
  1113.  
  1114. public GetSkillPoints( id )
  1115. {
  1116.     if( !get_pcvar_num( g_iEnableSkillPointsCmd ) )
  1117.     {
  1118.         ClientPrintColor( id, "!g%s!n Command disabled", PREFIX )
  1119.     }
  1120.    
  1121.     else
  1122.     {
  1123.         if( g_iLevels[ id ] < ( MAX_LEVELS - 1 ) )
  1124.         {
  1125.             ClientPrintColor( id, "!g%s!n Total points:!t %d!n Level:!t %s!n Points to the next level:!t %d", PREFIX, g_iPoints[ id ], CLASSES[ g_iLevels[ id ] ], ( LEVELS[ g_iLevels[ id ] ] - g_iPoints[ id ] ) )
  1126.         }
  1127.        
  1128.         else
  1129.         {
  1130.             ClientPrintColor( id, "!g%s!n Total points:!t %d!n Level:!t %s!n (last level)", PREFIX, g_iPoints[ id ], CLASSES[ g_iLevels[ id ] ] )
  1131.         }
  1132.     }
  1133.    
  1134.     return ( get_pcvar_num( g_iHideCmds ) == 0 ) ? PLUGIN_CONTINUE : PLUGIN_HANDLED_MAIN
  1135. }
  1136.  
  1137. public ChatAdvertisements( )
  1138. {
  1139.     new Players[ MAX_PLAYERS ]
  1140.     new iNum
  1141.     new i
  1142.    
  1143.     get_players( Players, iNum, "ch" )
  1144.    
  1145.     for( --iNum; iNum >= 0; iNum-- )
  1146.     {
  1147.         i = Players[ iNum ]
  1148.        
  1149.         ClientPrintColor( i, g_ChatAdvertise[ g_iK ], PREFIX )
  1150.     }
  1151.    
  1152.     g_iK++
  1153.    
  1154.     if( g_iK >= sizeof g_ChatAdvertise )
  1155.     {
  1156.         g_iK = 0
  1157.     }
  1158. }
  1159.  
  1160. public CmdGivePoints( id, level, cid )
  1161. {
  1162.     if ( !cmd_access( id, level, cid, 3 ) )
  1163.     {
  1164.         return PLUGIN_HANDLED
  1165.     }
  1166.    
  1167.     new Arg1[ 32 ]
  1168.     new Arg2[ 6 ]
  1169.    
  1170.     read_argv( 1, Arg1, charsmax( Arg1 ) )
  1171.     read_argv( 2, Arg2, charsmax( Arg2 ) )
  1172.    
  1173.     new iPlayer = cmd_target( id, Arg1, 1 )
  1174.     new iPoints = str_to_num( Arg2 )
  1175.    
  1176.     if ( !iPlayer )
  1177.     {
  1178.         console_print( id, "Sorry, player %s could not be found or targetted!", Arg1 )
  1179.         return PLUGIN_HANDLED
  1180.     }
  1181.    
  1182.     if( iPoints > 0 )
  1183.     {
  1184.         g_iPoints[ iPlayer ] += iPoints
  1185.         CheckLevelAndSave( iPlayer )
  1186.        
  1187.         if( get_pcvar_num( g_iEnableAnnounceOnChat ) )
  1188.         {
  1189.             ClientPrintColor( 0, "!g%s!n %s gave!t %i!n SkillPoint%s to %s", PREFIX, g_szName[ id ], iPoints, iPoints > 1 ? "s" : "", g_szName[ iPlayer ] )
  1190.         }
  1191.     }
  1192.    
  1193.     return PLUGIN_HANDLED
  1194. }
  1195.  
  1196. public CmdTakePoints( id, level, cid )
  1197. {
  1198.     if ( !cmd_access( id, level, cid, 3 ) )
  1199.     {
  1200.         return PLUGIN_HANDLED
  1201.     }
  1202.    
  1203.     new Arg1[ 32 ]
  1204.     new Arg2[ 6 ]
  1205.    
  1206.     read_argv( 1, Arg1, charsmax( Arg1 ) )
  1207.     read_argv( 2, Arg2, charsmax( Arg2 ) )
  1208.    
  1209.     new iPlayer = cmd_target( id, Arg1, 1 )
  1210.     new iPoints = str_to_num( Arg2 )
  1211.    
  1212.     if ( !iPlayer )
  1213.     {
  1214.         console_print( id, "Sorry, player %s could not be found or targetted!", Arg1 )
  1215.         return PLUGIN_HANDLED
  1216.     }
  1217.    
  1218.     if( iPoints > 0 )
  1219.     {
  1220.         g_iPoints[ iPlayer ] -= iPoints
  1221.         CheckLevelAndSave( iPlayer )
  1222.        
  1223.         if( get_pcvar_num( g_iEnableAnnounceOnChat ) )
  1224.         {
  1225.             ClientPrintColor( 0, "!g%s!n %s take!t %i!n SkillPoint%s from %s", PREFIX, g_szName[ id ], iPoints, iPoints > 1 ? "s" : "", g_szName[ iPlayer ] )
  1226.         }
  1227.     }
  1228.    
  1229.     return PLUGIN_HANDLED
  1230. }
  1231.  
  1232. public RestartSkillPoints( id )
  1233. {
  1234.     if( !get_pcvar_num( g_iEnableSkillPointsRestart ) )
  1235.     {
  1236.         ClientPrintColor( id, "!g%s!n Command disabled", PREFIX )
  1237.     }
  1238.    
  1239.     else
  1240.     {
  1241.         g_iPoints[ id ] = 0
  1242.         g_iLevels[ id ] = 0
  1243.         g_iClasses[ id ] = 0
  1244.        
  1245.         g_iKills[ id ] = 0
  1246.         g_iDeaths[ id ] = 0
  1247.         g_iHeadShots[ id ] = 0
  1248.         g_iKnifeKills[ id ] = 0
  1249.         g_iKnifeDeaths[ id ] = 0
  1250.         g_iGrenadeKills[ id ] = 0
  1251.         g_iGrenadeDeaths[ id ] = 0
  1252.         g_iBombExplosions[ id ] = 0
  1253.         g_iDefusedBombs[ id ] = 0
  1254.         g_iWonRounds[ id ] = 0
  1255.        
  1256.         CheckLevelAndSave( id )
  1257.        
  1258.         if( get_pcvar_num( g_iEnableAnnounceOnChat ) )
  1259.         {
  1260.             ClientPrintColor( id, "!g%s!n Your SkillPoints and level will start again", PREFIX )
  1261.         }
  1262.     }
  1263.    
  1264.     return ( get_pcvar_num( g_iHideCmds ) == 0 ) ? PLUGIN_CONTINUE : PLUGIN_HANDLED_MAIN
  1265. }
  1266.  
  1267. public FwdPlayerSpawnPost( id )
  1268. {   
  1269.     if( is_user_alive( id ) )
  1270.     {
  1271.         g_iCurrentKills[ id ] = 0
  1272.        
  1273.         if( get_pcvar_num( g_iEnableShowSkillPointsOnNick ) )
  1274.         {
  1275.             new szName[ 32 ]
  1276.             get_user_info( id, "name", szName, charsmax( szName ) )
  1277.            
  1278.             new iLen = strlen( szName )
  1279.            
  1280.             new iPos = iLen - 1
  1281.            
  1282.             if( szName[ iPos ] == '>' )
  1283.             {    
  1284.                 new i
  1285.                 for( i = 1; i < 7; i++ )
  1286.                 {    
  1287.                     if( szName[ iPos - i ] == '<' )
  1288.                     {    
  1289.                         iLen = iPos - i
  1290.                         szName[ iLen ] = EOS
  1291.                         break
  1292.                     }
  1293.                 }
  1294.             }
  1295.            
  1296.             format( szName[ iLen ], charsmax( szName ) - iLen, szName[ iLen-1 ] == ' ' ? "<%d>" : " <%d>", g_iPoints[ id ] )    
  1297.             set_user_info( id, "name", szName )
  1298.         }
  1299.     }
  1300. }
  1301.  
  1302. public MessageSayText( iMsgID, iDest, iReceiver )
  1303. {
  1304.     if( get_pcvar_num( g_iHideChangeNickNotification ) )
  1305.     {
  1306.         new const Cstrike_Name_Change[ ] = "#Cstrike_Name_Change"
  1307.        
  1308.         new szMessage[ sizeof( Cstrike_Name_Change ) + 1 ]
  1309.         get_msg_arg_string( 2, szMessage, charsmax( szMessage ) )
  1310.        
  1311.         if( equal( szMessage, Cstrike_Name_Change ) )
  1312.         {
  1313.             return PLUGIN_HANDLED
  1314.         }
  1315.     }
  1316.    
  1317.     return PLUGIN_CONTINUE
  1318. }
  1319.  
  1320. ClientPrintColor( id, String[ ], any:... )
  1321. {
  1322.     new szMsg[ 190 ]
  1323.     vformat( szMsg, charsmax( szMsg ), String, 3 )
  1324.    
  1325.     replace_all( szMsg, charsmax( szMsg ), "!n", "^1" )
  1326.     replace_all( szMsg, charsmax( szMsg ), "!t", "^3" )
  1327.     replace_all( szMsg, charsmax( szMsg ), "!g", "^4" )
  1328.    
  1329.     static msgSayText = 0
  1330.     static fake_user
  1331.    
  1332.     if( !msgSayText )
  1333.     {
  1334.         msgSayText = get_user_msgid( "SayText" )
  1335.         fake_user = get_maxplayers( ) + 1
  1336.     }
  1337.    
  1338.     message_begin( id ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, msgSayText, _, id )
  1339.     write_byte( id ? id : fake_user )
  1340.     write_string( szMsg )
  1341.     message_end( )
  1342. }
  1343.  
  1344.  
  1345.  
  1346.  
  1347.  


Kai pridedam klasę ir lygių nepamirštam pasikeist
#define MAX_CLASSES 2
#define MAX_LEVELS 2


Paskutinį kartą redagavo nullatonce 2017 Sau 16 01:55. Iš viso redaguota 3 kartus.


_________________
Atsijungęs
 Aprašymas  
 
 Pranešimo tema: Re: Basic SkillPoints v2.0.2 [šiek tiek redaguotas]
Žinutės numeris: #2  StandartinėParašytas: 2017 Vas 01 16:43 
Jau perkopė 10 žinučių ribą !

Užsiregistravo: 2017 Sau 30 18:08
Pranešimai: 17
Karma: 0
Gal išeitų padaryti, kad kai rašai rašytų tarkim: [BRONZE] Nick: Text
PS. Serveryje dar bus įdėtas pluginas kuris prie nick rašo vip/adm ir pnš.


Atsijungęs
 Aprašymas  
 
 Pranešimo tema: Re: Basic SkillPoints v2.0.2 [šiek tiek redaguotas]
Žinutės numeris: #3  StandartinėParašytas: 2017 Vas 15 23:59 
O taip. Jis jau surinko 50 žinučių!
Vartotojo avataras

Užsiregistravo: 2016 Rgs 06 23:57
Pranešimai: 62
Karma: 2
Išeitų, pasiskaityk plugino autoriaus temą.
Paveikslėlis


pavadinimus rašom tarp " <...> " , po kiekvieno pavadinimo nepamirštam pridėt , (kablelio) (išskyrus paskutinį elementą).
pvz.:
  1. "Mano rangas",
  2. "Kitas mano rangas",
  3. "Paskutinis mano rangas"


po kiekvieno skaičiaus nepamirštam pridėt , (kabelelio) (išskyrus paskutinį elementą).
pvz.:



#define MAX_CLASSES 5
#define MAX_LEVELS 5

MAX_CLASSES ir MAX_LEVELS įrašom skaičių kiek yra klasių ir levelių

pateiktuose pavyzdžiuose būtų
  1.  
  2. #define MAX_CLASSES    3
  3. #define MAX_LEVELS    3
  4.  



------------------------
Dėl plugino nežinau..



_________________
Atsijungęs
 Aprašymas  
 
 Pranešimo tema: Re: Basic SkillPoints v2.0.2 [šiek tiek redaguotas]
Žinutės numeris: #4  StandartinėParašytas: 2017 Vas 16 15:06 
Jau perkopė 10 žinučių ribą !

Užsiregistravo: 2017 Sau 30 18:08
Pranešimai: 17
Karma: 0
nullatonce rašė:
Išeitų, pasiskaityk plugino autoriaus temą.
Paveikslėlis


pavadinimus rašom tarp " <...> " , po kiekvieno pavadinimo nepamirštam pridėt , (kablelio) (išskyrus paskutinį elementą).
pvz.:
  1. "Mano rangas",
  2. "Kitas mano rangas",
  3. "Paskutinis mano rangas"


po kiekvieno skaičiaus nepamirštam pridėt , (kabelelio) (išskyrus paskutinį elementą).
pvz.:



#define MAX_CLASSES 5
#define MAX_LEVELS 5

MAX_CLASSES ir MAX_LEVELS įrašom skaičių kiek yra klasių ir levelių

pateiktuose pavyzdžiuose būtų
  1.  
  2. #define MAX_CLASSES    3
  3. #define MAX_LEVELS    3
  4.  



------------------------
Dėl plugino nežinau..

Tai sitą suprantu, bet aš klausiu ar galima, kad rašytų prie nick [LEVEL]
Nes dabar -
[SAVININKAS] Player <1324> : /rank
O norėtūsi
[SAVININKAS][LEVEL] Player: /rank


Atsijungęs
 Aprašymas  
 
 Pranešimo tema: Re: Basic SkillPoints v2.0.2 [šiek tiek redaguotas]
Žinutės numeris: #5  StandartinėParašytas: 2017 Vas 16 15:57 
O taip. Jis jau surinko 50 žinučių!
Vartotojo avataras

Užsiregistravo: 2016 Rgs 06 23:57
Pranešimai: 62
Karma: 2
Plugino autoriaus temą paskaityk, jokių nepaminėtų funkcijų neatjunginėjau



_________________
Atsijungęs
 Aprašymas  
 
Rodyti paskutinius pranešimus:  Rūšiuoti pagal  
 Puslapis 11 [ 5 pranešimai(ų) ] 

Visos datos yra UTC + 2 valandos


Dabar prisijungę

Vartotojai naršantys šį forumą: Registruotų vartotojų nėra ir 3 svečių


Jūs negalite kurti naujų temų šiame forume
Jūs negalite atsakinėti į temas šiame forume
Jūs negalite redaguoti savo pranešimų šiame forume
Jūs negalite trinti savo pranešimų šiame forume
Jūs negalite prikabinti failų šiame forume

Ieškoti:
Pereiti į:  

cron