Raised This Month: $ Target: $400
 0% 

get_user_info: Reading number command of the client, if "this" do "that" [...]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SpeedHacker.
Junior Member
Join Date: Dec 2008
Old 01-01-2009 , 19:30   get_user_info: Reading number command of the client, if "this" do "that" [...]
Reply With Quote #1

Hello,

I wanted a .sma plugin to read the color of the crosshair of a player (cl_crosshair_color), if "189 342 874" make the player
say "ExecScreen On" and if any other color rename the player to [ES-Off]"old name of the player":


PHP Code:
get_user_info(id"cl_crosshair_color",cl_crosshair_color31
if(
cl_crosshair_color == "152 132 854"){
client_print(id,print_chat,"[ ExecScreen On ]")
}
else{
client_cmd("name ^"[ES-Off]%s^"",name)
client_print(id,print_chat,"ExecScreen Off!")
client_print(id,print_console,"ExecScreen Off!")
client_print(id,print_notify,"ExecScreen Off!")
client_print(id,print_center,"ExecScreen Off!")

I tried but did not quite right :/
__________________

[img]http://img110.**************/img110/2851/1528sx6.gif[/img]


Last edited by SpeedHacker.; 01-02-2009 at 14:03.
SpeedHacker. is offline
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 01-01-2009 , 19:39   Re: get_user_info: Reading number command of the client, if "this" do "that" [...]
Reply With Quote #2

You cannot check to see if two strings are equal to each other by using two equal signs, you must use something like...

PHP Code:
new ex_crosshair_color[32]
get_user_info(id"cl_crosshair_color",ex_crosshair_color31)
 
if(
equal(ex_crosshair_color,"189 342 874"))
     
client_print(id,print_chat,"[ ExecScreen On ]")
else
{
     new 
PlayerName[44]
     
get_user_name(id,PlayerName,43)
     
client_cmd("name ^"[ES-Off]%s^"",PlayerName)
     
client_print(id,print_chat,"ExecScreen Off!")

__________________

Last edited by Bad_Bud; 01-01-2009 at 19:45.
Bad_Bud is offline
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 01-01-2009 , 19:45   Re: get_user_info: Reading number command of the client, if "this" do "that" [...]
Reply With Quote #3

I believe you need to use query_client_cvar for that.
__________________

Community / No support through PM
danielkza is offline
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 01-01-2009 , 19:48   Re: get_user_info: Reading number command of the client, if "this" do "that" [...]
Reply With Quote #4

What he said.

Also, it's not a bad idea to print out the string to make sure it was what you wanted.
__________________
Bad_Bud is offline
SpeedHacker.
Junior Member
Join Date: Dec 2008
Old 01-01-2009 , 21:22   Re: get_user_info: Reading number command of the client, if "this" do "that" [...]
Reply With Quote #5

Thank you!
It worked, but with each passing round the player to change nick, is [ES-Off] [ES-Off] "old name", [ES-Off] [ES-Off] [ES -
Off] "old name", ...
Is not making the name change only once?

PHP Code:
new ex_crosshair_color[32]
get_user_info(id"cl_crosshair_color",ex_crosshair_color31)
if(
equal(ex_crosshair_color,"152 132 854"))
     
client_print(id,print_chat,"[ ExecScreen On ]")
     new 
TAG[4]
     
get_user_name(id,TAG,4)
else if(
TAG<>[ES-Off])
{
     new 
PlayerName[44]
     
get_user_name(id,PlayerName,43)
     
client_cmd(id,"name ^"[ES-Off]%s^"",PlayerName)

__________________

[img]http://img110.**************/img110/2851/1528sx6.gif[/img]


Last edited by SpeedHacker.; 01-02-2009 at 14:02.
SpeedHacker. is offline
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 01-01-2009 , 22:44   Re: get_user_info: Reading number command of the client, if "this" do "that" [...]
Reply With Quote #6

You'd have to remove it before you change their name.

I don't have access to AMXX right now, but look in AMXX help under core, and you should find some "replace" function where you pass a string through, and then something to look for in the string and what to replace it with.
An example would be:

Code:
replace(PlayerName,"[ES-Off]","")
__________________
Bad_Bud is offline
SpeedHacker.
Junior Member
Join Date: Dec 2008
Old 01-01-2009 , 23:16   Re: get_user_info: Reading number command of the client, if "this" do "that" [...]
Reply With Quote #7

But how would this in code:
PHP Code:
public ResetHud(id){  
new 
ex_crosshair_color[32]
get_user_info(id"cl_crosshair_color",ex_crosshair_color31)
 
if(
equal(ex_crosshair_color,"152 132 854"))
     
client_print(id,print_chat,"[ ExecScreen On ]")
else
{
     new 
PlayerName[44]
     
get_user_name(id,PlayerName,43)
      
client_cmd(id,"name ^"[ES-Off]%s^"",PlayerName)
}
    return 
PLUGIN_HANDLED 

Where is the replace it?
I don't know AMXX much, I know programming in C/C++ only :/
__________________

[img]http://img110.**************/img110/2851/1528sx6.gif[/img]


Last edited by SpeedHacker.; 01-02-2009 at 14:01.
SpeedHacker. is offline
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 01-02-2009 , 06:42   Re: get_user_info: Reading number command of the client, if "this" do "that" [...]
Reply With Quote #8

I have items with specific models, and I store the model.mdl filename. I was pulling out the model from an entity, so it was returning a full path, such as "models/items/itemmodel.mdl". Since I only stored the last part, I had to cut out the first part. I ended up using replace, because I'm lazy, but I'll probably feel guilty and change it to string slicing later.

PHP Code:
replace(ItemsModels[0],48,"models/items/","")//Replaces "models/items" with "".
//Original string is ItemsModels[0], and the result overwrites whatever is in
//ItemsModels[0], making it contain "itemmodel.mdl" 
Another way to do this: http://forums.alliedmods.net/showthread.php?t=61367

You'll probably want to go with the replace option, because I think string slicing alters the flow of your plugin, kind of like a threaded query in sqlx.

You might be able to solve some future problems a lot quicker by consulting the function reference (the book on the bottom) and then expanding core at http://www.amxmodx.org/doc/

That's where you'll find explanations on replace, etc.
__________________

Last edited by Bad_Bud; 01-02-2009 at 06:46.
Bad_Bud is offline
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 01-02-2009 , 17:18   Re: get_user_info: Reading number command of the client, if "this" do "that" [...]
Reply With Quote #9

Quote:
Originally Posted by Bad_Bud View Post
You'll probably want to go with the replace option, because I think string slicing alters the flow of your plugin, kind of like a threaded query in sqlx.
What the hell are you smoking? String slicing does not do ANYTHING like that. Imagine how an array is stored:

|0|1|2|3|4|5|

String slicing just passes the array like it starts somewhere later
|3|4|5|

How could this alter the flow of anything?
__________________

Community / No support through PM
danielkza is offline
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 01-02-2009 , 18:31   Re: get_user_info: Reading number command of the client, if "this" do "that" [...]
Reply With Quote #10

He's a beginner with AMXX.

PHP Code:
new str_to_cut[] = "Cut us here| Woah important info"
 
stock testfunc(str[])
{
     new 
containi(str,"|")
     
parse_me(str[i])
}
 
stock parse_me(str[])
{
     
// Do stuff on string AFTER pipe

To split the string, you have to finish your flow of code after it's split (in the parse_me function).

Someone just learning AMXX would probably want to keep everything flowing in the same function they started in, because it's easier to follow.

Also, if he was running a loop and wanted to compare two split strings with each other, he couldn't... not that he's wanting to, but he may run into a similar problem later.
__________________

Last edited by Bad_Bud; 01-02-2009 at 18:34.
Bad_Bud 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 09:18.


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