Raised This Month: $ Target: $400
 0% 

get user name for comparing


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
shino
Senior Member
Join Date: May 2006
Old 07-04-2006 , 16:16   get user name for comparing
Reply With Quote #1

so, i would like to get player's name and compare it with the name of player i have picked when he wrote something. here's the code:
Code:
new TA[32],LA[32],LeaderA[32],CheckSay[128],TeamA,TeamALeaderDefined,BCTeamARdy public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR);     register_cvar("bc_teamA","NiP");     register_clcmd("say","check");     BCTeamARdy = 0     TeamALeaderDefined = 0     get_cvar_string("bc_teamA",TeamA,31); } public check(id) {     read_args( CheckSay, 127 );     remove_quotes( CheckSay );     format(LA,31,"!leader %s",TeamA);     format(TA,31,"%s ready",TeamA);     if(equal(CheckSay,LA)) {         TeamALeaderDefined = 1         get_user_name(id,LeaderA,31); // *** got his name ***         server_cmd("say %s has become leader of %s.",LeaderA,TeamA);         client_print(id,print_center,"It is very important for you to not rename from now on!");     }     if(TeamALeaderDefined == 1) {         if(equal(get_user_info(id,"name"),LeaderA)) { // here's the problem             if(equal(CheckSay,TA)) {                 BCTeamARdy = 1                 client_print(0,print_chat,"%s is ready!",TeamA );                 set_cvar_num("sv_restartround",2);             }         } else {             client_print(id,print_chat,"You are not authorized for this action")         }     } }

this is just a part of the code, so i might forgot some things.

how should i get his name?
shino is offline
L0neW0lf
Member
Join Date: Mar 2006
Location: Denmark
Old 07-04-2006 , 18:13   Re: get user name for comparing
Reply With Quote #2

You could use get_user_name(id, name[], len)

An example:
new name[18]
get_user_name(id, name, 17
)
client_print(id, print_chat, "Your name is: %s", name)
__________________
Enjoy getting older - The only alternative is death!
L0neW0lf is offline
Send a message via ICQ to L0neW0lf Send a message via MSN to L0neW0lf Send a message via Skype™ to L0neW0lf
L0neW0lf
Member
Join Date: Mar 2006
Location: Denmark
Old 07-04-2006 , 18:17   Re: get user name for comparing
Reply With Quote #3

Prematuer post can be deleted!
__________________
Enjoy getting older - The only alternative is death!

Last edited by L0neW0lf; 07-04-2006 at 18:22.
L0neW0lf is offline
Send a message via ICQ to L0neW0lf Send a message via MSN to L0neW0lf Send a message via Skype™ to L0neW0lf
L0neW0lf
Member
Join Date: Mar 2006
Location: Denmark
Old 07-04-2006 , 18:17   Re: get user name for comparing
Reply With Quote #4

I cant figure out precicly what you want?¿?

But an example how to compare name with your list:

Code:
new name[18] get_user_name(id, name, 17) if(equali(name[17],myName[17]) { //event or function } else { //event or function }


You can use equal instead of equali.
equal is case sensetive
equali is NOT case sensetive

/Lone Wolf
__________________
Enjoy getting older - The only alternative is death!

Last edited by L0neW0lf; 07-04-2006 at 18:22.
L0neW0lf is offline
Send a message via ICQ to L0neW0lf Send a message via MSN to L0neW0lf Send a message via Skype™ to L0neW0lf
shino
Senior Member
Join Date: May 2006
Old 07-05-2006 , 04:33   Re: get user name for comparing
Reply With Quote #5

Code:
public check(id) {         new LeadACheck[32]     read_args( CheckSay, 127 );     remove_quotes( CheckSay );     format(LA,31,"!leader %s",TeamA);     format(LB,31,"!leader %s",TeamB);     format(TA,31,"%s ready",TeamA);     format(TB,31,"%s ready",TeamB);     if(equal(CheckSay,LA)) {         TeamALeaderDefined = 1         get_user_name(id,LeaderA,31);         server_cmd("say %s has become leader of %s.",LeaderA,TeamA);         client_print(id,print_center,"It is very important for you to not rename from now on!");     }     if(TeamALeaderDefined == 1) {         if(equal(CheckSay,TA)) {             get_user_name(id,LeadACheck,31);             if(LeadACheck == LeaderA) {                         BCTeamARdy = 1                 client_print(0,print_chat,"%s is ready!",TeamA );                 set_cvar_num("sv_restartround",2);             }         } else {             client_print(id,print_chat,"You are not authorized for this action")         }     } }

when compiling, it shows:
Code:
Error: Array must be indexed (variable "LeadACheck") on line 76
shino is offline
L0neW0lf
Member
Join Date: Mar 2006
Location: Denmark
Old 07-05-2006 , 04:51   Re: get user name for comparing
Reply With Quote #6

Cant se the line numbers, but my guess is that it is this one:
Code:
if(LeadACheck == LeaderA)




Try these i instead:
Code:
if(equal(LeadACheck,LeaderA)) or if(LeadACheck = LeaderA) or if(LeadACheck[31]==LeaderA[31])



I havent figured it completly out the thing about = or == in if's

/Lone Wolf
__________________
Enjoy getting older - The only alternative is death!

Last edited by L0neW0lf; 07-05-2006 at 04:53.
L0neW0lf is offline
Send a message via ICQ to L0neW0lf Send a message via MSN to L0neW0lf Send a message via Skype™ to L0neW0lf
shino
Senior Member
Join Date: May 2006
Old 07-05-2006 , 04:53   Re: get user name for comparing
Reply With Quote #7

equal works great, thanks

in if's, == must be used
__________________


+karma if i am helpful
shino is offline
L0neW0lf
Member
Join Date: Mar 2006
Location: Denmark
Old 07-05-2006 , 04:54   Re: get user name for comparing
Reply With Quote #8

No problem
__________________
Enjoy getting older - The only alternative is death!
L0neW0lf is offline
Send a message via ICQ to L0neW0lf Send a message via MSN to L0neW0lf Send a message via Skype™ to L0neW0lf
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 18:30.


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