Raised This Month: $ Target: $400
 0% 

Storing user names?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
amxxsean
Member
Join Date: Feb 2005
Old 03-29-2005 , 16:57   Storing user names?
Reply With Quote #1

How would you store a users name so you can call the previous username to rename them back to normal.
For example. I type amx_god Billy and it changes their name to GOD. How would I change his name back to billy when I use amx_ungod or whatever.
And also, how do you make it put all people but the person with name "X" or whatever on a specific team. Thanks.
__________________
DID SOMEBODY DIAL TEH AWPERAT0RZ?
www.awpz.tk
NOW ACCEPTING MEMBERS!
amxxsean is offline
FeuerSturm
AlliedModders Donor
Join Date: Apr 2004
Old 03-29-2005 , 17:13  
Reply With Quote #2

1.)
you can store names in an indexed variable like new oldname[32][33] and then to get his name before you rename him:
get_user_name(targetid,oldname[targetid],32)
and to give back his old name:
client_cmd(targetid,"name %s",oldname[targetid])

2.)
once again you can use an index variable to make the player be skipped
for the team change like new nochange[32] and then
nochange[targetid] = 1

now you need to go through the players and see if you can switch them:
Code:
new players[32],playernum get_players(players, playernum) for(new i=0; i<playernum; i++){     if(is_user_connected(players[i]) == 1 && nochange(players[i]) == 0){         //your teamchange code here!     } }

i think you should get the point
FeuerSturm is offline
amxxsean
Member
Join Date: Feb 2005
Old 03-29-2005 , 17:20  
Reply With Quote #3

So would it look like this if the player index was uid:
Code:
new name[32] get_user_name(uid,name[uid],32);
And THEN you change the name?
__________________
DID SOMEBODY DIAL TEH AWPERAT0RZ?
www.awpz.tk
NOW ACCEPTING MEMBERS!
amxxsean is offline
FeuerSturm
AlliedModders Donor
Join Date: Apr 2004
Old 03-29-2005 , 17:25  
Reply With Quote #4

you obviously don't know what you're talking about.

if you index "name" only once, you don't get the userid with it,
just the name of the player.
so if you do that command on several players, the oldname will always
be overwritten with the oldname of the last player you saved.
the index you're trying to use is the lenght of the name the variable can store.
so you need to index it twice to store the name by the user's id.


do you think i wrote that all for nothing?
if you ask for help, take it and don't try to smartass the one that actually knows what he's talking about.
FeuerSturm is offline
amxxsean
Member
Join Date: Feb 2005
Old 03-29-2005 , 17:29  
Reply With Quote #5

Huh? Im not being smart! I just didn't know if the zero counted as a player spot. I didn't mean to make it offensive or anything... Where did that come from? And yes, I know you know what you are doing and I don't...

Edit: Ok now I understand why you need to put
Code:
new oldname[32][33]
__________________
DID SOMEBODY DIAL TEH AWPERAT0RZ?
www.awpz.tk
NOW ACCEPTING MEMBERS!
amxxsean is offline
FeuerSturm
AlliedModders Donor
Join Date: Apr 2004
Old 03-29-2005 , 17:31  
Reply With Quote #6

i actually don't know what "zero" you're talking about?!
FeuerSturm is offline
amxxsean
Member
Join Date: Feb 2005
Old 03-29-2005 , 17:38  
Reply With Quote #7

Nevermind the zero, that was my mistake lol. Like you said I have no idea what I'm doing. But anyhow, this is what I have for the name changing. I think its right.
Code:
new oldname[32][33]     get_user_name(uid,oldname[uid],32);
And then later on in the script it renames him with:
Code:
client_cmd(uid,"name %s",oldname[uid])
That would even rename him after his name was changed to "God" or whatever I choose to put in the script right? The name change won't effect uid will it?
__________________
DID SOMEBODY DIAL TEH AWPERAT0RZ?
www.awpz.tk
NOW ACCEPTING MEMBERS!
amxxsean is offline
FeuerSturm
AlliedModders Donor
Join Date: Apr 2004
Old 03-29-2005 , 17:41  
Reply With Quote #8

no, it won't, uid is the userid that the server assigned to that player.
you should keep in mind that the data is lost on mapchange though
as the variables are reset and the userid changes as players basically
reconnect to the server on a mapchange.

but as long as the same map runs it will work.
FeuerSturm is offline
amxxsean
Member
Join Date: Feb 2005
Old 03-29-2005 , 17:49  
Reply With Quote #9

Woot woot thanks. Ok now how would I go about moving all people but the one we just specified to the opposite team? Say he had the name "God", whats the function to move all people not having the uid number of "God" to team "X"? Or since you gave the the code for "God"s immunity to the move, whats the function to move players to another team. So it will be like "God" vs. all people in server.
__________________
DID SOMEBODY DIAL TEH AWPERAT0RZ?
www.awpz.tk
NOW ACCEPTING MEMBERS!
amxxsean is offline
FeuerSturm
AlliedModders Donor
Join Date: Apr 2004
Old 03-29-2005 , 18:00  
Reply With Quote #10

well, i don't know the team numbers in cs or any other mod,
maybe an example for dod helps, you just have to find the correct numbers
for your mod (probably the same, i don't know).

Team Allies = 1; Team Axis = 2; Team Spec = 3; Team Random = 5 (dod values)

let's say we move all players to axis and only "God" to allies:


Code:
new players[32],playernum get_players(players, playernum) for(new i=0; i<playernum; i++){     if(is_user_connected(players[i]) == 1 && get_user_team(players[i]) != 2 && one_vs_all(players[i]) == 0){         engclient_cmd(players[i],"jointeam","2")     }     else if(is_user_connected(players[i]) == 1 && get_user_team(players[i]) != 1 && one_vs_all(players[i]) == 1){         engclient_cmd(players[i],"jointeam","1")     } }

i renamed the variable to one_vs_all as it fits better
so all players that aren't already on Axis (get_user_team(players[i]) != 2)
will join that team but not the chosen one (one_vs_all(players[i]) == 0)
and the chosen one (one_vs_all(players[i]) == 1) will join allies if he's not already on that team (get_user_team(players[i]) != 1).

that's just the basics, you will have to block changing teams and stuff like that as well
FeuerSturm is offline
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 10:02.


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