get_user_info: Reading number command of the client, if "this" do "that" [...]
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:
|
Re: get_user_info: Reading number command of the client, if "this" do "that" [...]
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:
|
Re: get_user_info: Reading number command of the client, if "this" do "that" [...]
I believe you need to use query_client_cvar for that.
|
Re: get_user_info: Reading number command of the client, if "this" do "that" [...]
What he said.
Also, it's not a bad idea to print out the string to make sure it was what you wanted. |
Re: get_user_info: Reading number command of the client, if "this" do "that" [...]
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:
|
Re: get_user_info: Reading number command of the client, if "this" do "that" [...]
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]","") |
Re: get_user_info: Reading number command of the client, if "this" do "that" [...]
But how would this in code:
PHP Code:
I don't know AMXX much, I know programming in C/C++ only :/ |
Re: get_user_info: Reading number command of the client, if "this" do "that" [...]
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:
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. |
Re: get_user_info: Reading number command of the client, if "this" do "that" [...]
Quote:
|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? |
Re: get_user_info: Reading number command of the client, if "this" do "that" [...]
He's a beginner with AMXX.
PHP Code:
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. |
| All times are GMT -4. The time now is 09:18. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.