Raised This Month: $ Target: $400
 0% 

make a whole plugin only work with flagged users


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Plug me up
Member
Join Date: Aug 2008
Old 01-18-2009 , 19:34   make a whole plugin only work with flagged users
Reply With Quote #1

hi, another problem this time... i just found NL)Ramon(NL unimilited money code and was trying to make it only work with players with acess flag d. Guess what! no lucky at all, this time, dont even know how to start
if any1 got time, help are pretty welcome
there are the code:

Code:
//#include <amxmodx>
#include <money_ul>
#include <amxmisc>
#include <cstrike>
#define MONEY_TIER 8000 // DON'T MESS WITH, Money total at which the plugin switches over keeping track of money
new money_total[33] // Keep track of peeps money if above MONEY_TIER
new gmsg_Money
new amx_maxmoney
new amx_startmoney
public client_connect(id)
{
 set_cvar_float("mp_startmoney", 801.0) // So you can track when to change to amx_startmoney ammount, I know.. a crude method
 money_total[id] = 0
}

public read_gmsg_Money(id) {
 if(!is_user_connected(id)) return PLUGIN_HANDLED
 
 new current_total = read_data(1)
 
 if(current_total == 801){         // If CS is spawning you with mp_startmoney default
  current_total = get_pcvar_num(amx_startmoney)      // current total is actually amx_startmoney
  cs_set_user_money_ul(id, current_total,0)         // so set user money to amx_startmoney
  money_total[id] = 0 // reset
 }
 if(current_total >= MONEY_TIER && !money_total[id]) // If first time above MONEY_TIER
 {
  money_total[id] = current_total // Keep track of current total
  
  send_moneymsg(id,current_total-MONEY_TIER,read_data(2)) // send money msg of current total
  
  return PLUGIN_CONTINUE
 }
 if(money_total[id]) // If was over tier on last money message
 {
  money_total[id] += current_total - MONEY_TIER  // figure the term of current total - tier
  
  if(money_total[id] < MONEY_TIER){  // If less then tier set user money to money_total[id] and stop keeping track
   cs_set_user_money_ul(id,money_total[id],1)
   money_total[id] = 0
  }
  else{
   send_moneymsg(id,current_total-MONEY_TIER,read_data(2)) // else send money message
  }
  
  return PLUGIN_CONTINUE
 }
 
 return PLUGIN_CONTINUE
}
//change flash to ammount
public send_moneymsg(id,ammount,flash)
{
 cs_set_user_money_ul(id,MONEY_TIER,0) //Set user money to tier ammount so easy to track add and subtract terms
 
 new maxamount = get_pcvar_num(amx_maxmoney)
 
 if(money_total[id] >  maxamount)
  money_total[id] =  maxamount
 
 //send old money
 message_begin( MSG_ONE , gmsg_Money , {0,0,0}, id )
 write_long(money_total[id]-ammount)
 write_byte(0)
 message_end()
 
 //send current money
 message_begin( MSG_ONE , gmsg_Money , {0,0,0}, id ) //Send money message with ammount stored in money_total[id]
 write_long(money_total[id])
 write_byte(flash)
 message_end()
}

public find_money_target(id, level, cid)
{
 if(!cmd_access(id, level, cid, 3))
  return PLUGIN_HANDLED
 
 new target[16], ammount[8], players[32]
 new num
 
 read_argv(1,target,15)
 read_argv(2,ammount,7)
 
 if(target[0] == '@'){    //If trying to give a team money
  if(target[1] == 'C' || target[1] == 'c'){
   get_players(players, num ,"e", "CT")
  }
  else if(target[1] == 'T' || target[1] == 't'){
   get_players(players, num ,"e", "TERRORIST")
  }
  else{
   console_print(id, "*** No known team by that name. ***")
   return PLUGIN_HANDLED
  }
 }
 else if(target[0] == '#'){  //If trying to give a player(userid) money
  new userid = str_to_num(target[1])
  players[0] = find_player("k", userid)
 }
 else{  // else search for matching name to try and give money
  players[0] = find_player("bl", target)
 }
 
 if(players[0] == 0){  //If no target(s) could be found
  console_print(id, "*** No target(s) could be found. ***")
  return PLUGIN_HANDLED
 }
 else 
  give_money(players, str_to_num(ammount))
 
 return PLUGIN_HANDLED
}

public give_money(players[], ammount)
{
 new i
 while(players[i]){
  if(money_total[players[i]]){
   money_total[players[i]] += ammount // Keep track of current total
   send_moneymsg(players[i],ammount,1) // send money msg of current total
  }
  else if( (cs_get_user_money_ul(players[i]) + ammount) >= MONEY_TIER){
   money_total[players[i]] = cs_get_user_money_ul(players[i]) + ammount // Keep track of current total
   send_moneymsg(players[i],ammount,1) // send money msg of current total
  }
  else{
   ammount += cs_get_user_money_ul(players[i])
   cs_set_user_money_ul(players[i],ammount,1)
   money_total[players[i]] = 0
  }
  
  ++i
 }
}
public restartround() 
{ 
 for (new i=1; i<33; i++)
  money_total[i] = 0
} 
public _cs_get_user_money_ul(plug,param) {
 if(param != 1)
  return PLUGIN_HANDLED
 
 new id = get_param(1)
 
 
 if (id < 1 || id > get_maxplayers()) {
  log_error(AMX_ERR_NATIVE, "Player out of range (%d)", id)
  return PLUGIN_HANDLED
  } else {
  if (!is_user_connected(id)) {
   log_error(AMX_ERR_NATIVE, "Invalid player %d", id)
   return PLUGIN_HANDLED
  }
 }
 
 if(money_total[id] < MONEY_TIER) {
  return cs_get_user_money_ul(id)
 }
 else {
  return money_total[id]
 }
 
 return PLUGIN_HANDLED
 
}
public _cs_set_user_money_ul(plug,param) {
 if(param != 2 && param != 3 )
  return PLUGIN_HANDLED
 
 new id = get_param(1)
 
 if (id < 1 || id > get_maxplayers()) {
  log_error(AMX_ERR_NATIVE, "Player out of range (%d)", id)
  return PLUGIN_HANDLED
  } else {
  if (!is_user_connected(id)) {
   log_error(AMX_ERR_NATIVE, "Invalid player %d", id)
   return PLUGIN_HANDLED
  }
 }
 
 new ammount = get_param(2)
 
 if(ammount >= MONEY_TIER){
  new change = ammount - money_total[id]
  money_total[id] = ammount
  send_moneymsg(id,change,get_param(3))
 }
 else{
  if (ammount < 0) ammount = 0
  cs_set_user_money_ul(id,ammount,get_param(3))
  money_total[id] = 0
 }
 return PLUGIN_HANDLED 
}
public plugin_natives() {
 register_library("money_ul")
 register_native("cs_get_user_money_ul","_cs_get_user_money_ul")
 register_native("cs_set_user_money_ul","_cs_set_user_money_ul")
}
public plugin_init()
{
 register_plugin("Unlimited Money","2.0","NL)Ramon(NL")
 
 register_event("Money","read_gmsg_Money","b")
 register_event("TextMsg", "restartround", "a", "2&#Game_C","2&#Game_w") 
 
 amx_startmoney = register_cvar("amx_startmoney", "800")
 amx_maxmoney = register_cvar("amx_maxmoney", "99999")
 
 register_concmd("amx_setmoney", "find_money_target",ADMIN_BAN, "{@team, #userid, or name(can be partial)} <ammount>")
 
 gmsg_Money = get_user_msgid("Money")
 
 return PLUGIN_CONTINUE
}
__________________
always +karma to thoose who helps
Plug me up is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 01-18-2009 , 22:59   Re: make a whole plugin only work with flagged users
Reply With Quote #2

Where ever the plugin is called put this

PHP Code:
if(!is_user_admin(id))
{
   return 
PLUGIN_HANDLED

right?
Doc-Holiday is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 01-19-2009 , 06:25   Re: make a whole plugin only work with flagged users
Reply With Quote #3

Quote:
Originally Posted by Plug me up View Post
make it only work with players with acess flag d.
Quote:
Originally Posted by NcB_Sav View Post
Where ever the plugin is called put this

PHP Code:
if(!is_user_admin(id))
{
   return 
PLUGIN_HANDLED

right?
How do you think that is_user_admin, could have something to do with flag d? Anyway...
Code:
if(get_user_flags(index) & ADMIN_BAN)
      //User has flag admin_ban (what's d flag)
if(~get_user_flags(index) & ADMIN_BAN)
     //User doesn't, so you can return handled here if it fits your needs.
SnoW is offline
Send a message via MSN to SnoW
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 01-19-2009 , 12:23   Re: make a whole plugin only work with flagged users
Reply With Quote #4

Quote:
Originally Posted by SnoW View Post
How do you think that is_user_admin, could have something to do with flag d? Anyway...
Code:
if(get_user_flags(index) & ADMIN_BAN)
      //User has flag admin_ban (what's d flag)
if(~get_user_flags(index) & ADMIN_BAN)
     //User doesn't, so you can return handled here if it fits your needs.

didnt see the whole post. and typo.

if(!get_user_flags(index) & ADMIN_BAN)

question wouldnt
PHP Code:
if(get_user_flags(id) != ADMIN_BAN)
plugin return 1

work to block someting as well if user dosent have admin ban
Doc-Holiday is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-19-2009 , 12:28   Re: make a whole plugin only work with flagged users
Reply With Quote #5

No.
!= means they aren't the values.
That means the player must have the ban flags only.

Also, that wasn't a typo.
Learn scripting before you criticize.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Plug me up
Member
Join Date: Aug 2008
Old 01-19-2009 , 14:42   Re: make a whole plugin only work with flagged users
Reply With Quote #6

Quote:
//User has flag admin_ban (what's d flag)
hahaha sorry, "acess flag d" means admin_level_d


Man this plugin is giving me a huge headache. Spend all my evening on this and nothing!!

i cant find a way to the plugin do its stuff with admin_level_d players, and dont do anything at all with players that dont have the flag.

im almost giving up of this plug

------------------------
NO KIDDDING!!!
hahhaha righ after i post it i hav a epiphany! soooooooo easy!

Quote:
if(!is_user_connected(id)) return PLUGIN_HANDLED
if(~get_user_flags(id) & ADMIN_LEVEL_D) return PLUGIN_HANDLED
its just add snow's line and than voilá!!

(and unfortunately i cant add more karma to snow, forum prohibits me)
__________________
always +karma to thoose who helps

Last edited by Plug me up; 01-19-2009 at 14:56. Reason: epiphany kkkkk
Plug me up is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 01-19-2009 , 15:17   Re: make a whole plugin only work with flagged users
Reply With Quote #7

PHP Code:
if(!is_user_connected(id) || !(get_user_flags(id) & ADMIN_LEVEL_D))
     return 
PLUGIN_HANDLED
same in one line ;)
__________________
xPaw is offline
Reply


Thread Tools
Display Modes

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 01:39.


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