Raised This Month: $32 Target: $400
 8% 

Solved Help admin acces laser sight


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Barlap
Senior Member
Join Date: Apr 2016
Location: Romania
Old 12-17-2020 , 14:46   Help admin acces laser sight
Reply With Quote #1

Hello guys can somebody help me with this code?
It's a laser sight plugin, i want to make it work only for users with "t" flag, i tried something but not working, can you check the code bellow?
Code:
#include <amxmodx>

#define MAX_TEAMS 4
#define VIPICE	ADMIN_LEVEL_H

new sprite
new numwpns
new weapons[32]

new ls_enabled
new ls_line
new ls_pvis
new ls_wpns
new ls_rgb

new numteams
new rgb[3][MAX_TEAMS]

public plugin_init()
{
	register_plugin("Lasers","0.5","Toster v2.1")
	
	ls_enabled = register_cvar("ls_enabled", "1")
	ls_line = register_cvar("ls_line", "1")
	ls_pvis = register_cvar("ls_pvis", "0")
	ls_wpns = register_cvar("ls_wpns", "0;1;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;19;20;21;22;23;24;25;26;27;28;29;30;")
	ls_rgb = register_cvar("ls_rgb", "255 0 0;")
	
	register_clcmd("ls_refresh", "getcvars", ADMIN_KICK)
	register_clcmd("ls_getteam", "getteam", ADMIN_KICK)
	register_clcmd("ls_getwpn", "getwpn", ADMIN_KICK)
	
	getcvars()
}

public getwpn(id)
{
	new clip, ammo
	new w = get_user_weapon(id, clip, ammo)
	
	console_print(id, "[ls] Your current weapon's id: %d", w)
	return PLUGIN_HANDLED
}

public getteam(id)
{
	new t = get_user_team(id)
	console_print(id, "[ls] Your current team's id: %d", t)
	return PLUGIN_HANDLED
}

public getcvars()
{
	getwpns()
	getrgb()
	
	return PLUGIN_HANDLED
}

public getrgb()
{
	new txt[MAX_TEAMS * 16]
	new team[MAX_TEAMS][16]
	new tmp[4]
	
	get_pcvar_string(ls_rgb, txt, 64)
	add(txt, 64, " ")
	
	for(numteams = 0; contain(txt, ";")!=-1; numteams++)
	{
	  strtok(txt, team[numteams], 16, txt, MAX_TEAMS * 16, ';')
	  
	  for(new i=0; i<2; i++)
	  {
	    strtok(team[numteams], tmp, 4, team[numteams], 16, ' ')
	    rgb[i][numteams] = str_to_num(tmp)
	  }
	  trim(team[numteams])
	  rgb[2][numteams] = str_to_num(team[numteams])
	  
	  trim(txt)
	}
}

public getwpns()
{
	new txt[64]
	new wpns[3]
	
	get_pcvar_string(ls_wpns, txt, 64)
	add(txt, 64, " ")
	
	for(numwpns = 0; contain(txt, ";")!=-1; numwpns++)
	{
	  strtok(txt, wpns, 3, txt, 64, ';')
	  weapons[numwpns] = str_to_num(wpns)
	}
}

public plugin_precache() 
{
	sprite = precache_model("sprites/white.spr")
}

public client_PreThink(id)
{
	if(!is_user_alive(id)||get_pcvar_num(ls_enabled)!=1) return PLUGIN_HANDLED
	
	new clip, ammo
	new w = get_user_weapon(id, clip, ammo)
	
	for(new i=0; i<numwpns; i++) if(w == weapons[i]) return PLUGIN_HANDLED
	
	new e[3]
	new t = get_user_team(id)
	
	get_user_origin(id, e, 3)
	
	if(get_pcvar_num(ls_pvis) == 0)message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
	else message_begin( MSG_ONE_UNRELIABLE,SVC_TEMPENTITY, _, id)
	
	if(get_user_flags(id) == VIPICE || get_pcvar_num(ls_line) != 0)
	{
	  write_byte (TE_BEAMENTPOINT)
	  write_short(id | 0x1000)
	  write_coord (e[0])
	  write_coord (e[1])
	  write_coord (e[2])
	}
	else
	{
	  write_byte (0)
	  write_coord (e[0] + 1)
	  write_coord (e[1] + 1)
	  write_coord (e[2] + 1)
	  write_coord (e[0] - 1)
	  write_coord (e[1] - 1)
	  write_coord (e[2] - 1)
	}
	
	write_short(sprite)
	write_byte (0)      						
	write_byte (10)     						
	write_byte (1)
	write_byte (5)   						
	write_byte (0)    
	
	if(numteams>=t)  
	{
	  write_byte (rgb[0][t-1]) 	
	  write_byte (rgb[1][t-1])
	  write_byte (rgb[2][t-1])
	}
	else
	{
	  write_byte (rgb[0][0]) 	
	  write_byte (rgb[1][0])
	  write_byte (rgb[2][0])
	}
	
	write_byte (255)     						
	write_byte (10)      						
	message_end()
	
	return PLUGIN_HANDLED
}

Last edited by Barlap; 12-18-2020 at 12:41.
Barlap is offline
Send a message via ICQ to Barlap Send a message via Skype™ to Barlap
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 12-17-2020 , 14:55   Re: Help admin acces laser sight
Reply With Quote #2

get_user_flags(id) & VIP_ICE
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Barlap
Senior Member
Join Date: Apr 2016
Location: Romania
Old 12-17-2020 , 16:24   Re: Help admin acces laser sight
Reply With Quote #3

Not working, all users can use the laser sight
Barlap is offline
Send a message via ICQ to Barlap Send a message via Skype™ to Barlap
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 12-17-2020 , 17:33   Re: Help admin acces laser sight
Reply With Quote #4

That's because the check is not in the proper place. Place it in the beginning of the function and stop it if it's false.
__________________

Last edited by OciXCrom; 12-17-2020 at 17:33.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 12-17-2020 , 20:48   Re: Help admin acces laser sight
Reply With Quote #5

You said.
Quote:
It's a laser sight plugin, i want to make it work only for users with "t" flag,
but.
Code:
#define VIPICE	ADMIN_LEVEL_H
__________________
GitHub
SteamWishlist

六四天安門事件
+ARUKARI- is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 12-17-2020 , 21:24   Re: Help admin acces laser sight
Reply With Quote #6

inside client_prethink add whats highlighted in red.

Code:
if(!is_user_alive(id)||!(get_user_flags(id) & VIP_ICE)||get_pcvar_num(ls_enabled)!=1) return PLUGIN_HANDLED
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 12-18-2020 , 07:38   Re: Help admin acces laser sight
Reply With Quote #7

Quote:
Originally Posted by +ARUKARI- View Post
You said.


but.
Code:
#define VIPICE	ADMIN_LEVEL_H
There's nothing wrong there. ADMIN_LEVEL_H is flag "t".
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 12-18-2020 , 07:47   Re: Help admin acces laser sight
Reply With Quote #8

omg, Looks like I've been wrong for 16 years.
__________________
GitHub
SteamWishlist

六四天安門事件
+ARUKARI- is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 12-18-2020 , 10:07   Re: Help admin acces laser sight
Reply With Quote #9

lmao..

that's alot period of time....
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 12-18-2020 at 10:08.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Barlap
Senior Member
Join Date: Apr 2016
Location: Romania
Old 12-18-2020 , 12:40   Re: Help admin acces laser sight
Reply With Quote #10

Thx guys
Barlap is offline
Send a message via ICQ to Barlap Send a message via Skype™ to Barlap
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 20:48.


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