What happened to OC? - CLOSED Carnage?!
Sign in to follow this  
Followers 0
Devieth

OnNameRequest & Read/Write_widestring

This basically gives you the same power that the OnNameRequest in Phasor did. So this will allow you to change the players name as they join the server, making their name in the scoreboard, chat, and kill feed become the name you set.
 
OnNameRequest
 
Example:

https://youtu.be/259by3MEjRc


 
Note: You can just pull the read/write_widestring right out of this script and use it as needed (although I am not sure of any other practical uses.)

WaeV likes this

Share this post


Link to post
Share on other sites

Tiddy-bits:

Sounds like the ultimate framing tool.

NeX likes this

"You're nothing but a thing to me." -Tucker933 2016   

"Mine's not huge, but neither are my hands, so it's a real good fit." -Badga666 2017                

"It's not incest until it's in." -Caesar 2017

"Poison dart frogs aren't poisonous. Mankind is a poison and the dart frogs are the cure." -Somewhere on the internet 

"I felt left out so I added myself to your signature." -Pfhunkie 2020

"English isn't my primary language. It's also the only language I know." -ShikuTeshi ????
"In the quiet the silence is louder." -My Sister 2021

Share this post


Link to post
Share on other sites

Sounds like the ultimate framing tool.

In Phasor it was used for banning specific names or blocking people from impersonating clan members/admins.

Share this post


Link to post
Share on other sites

A few issues:

 

You forgot OnScriptUnload(), which will cause an error to occur every time the script is unloaded. It doesn't break anything, nor will it be noticeable by many people, but it's noticeable to me, which is why I put that here. A simple "OnScriptUnload() end" put at the end of the script is enough if you're not going to use it.

 

Also, OnNameRequest()'s Name variable is actually the name of the last player to take that player slot, rather than the player's actual name, meaning that if a new player joins, they will have the name of the previous player who was in that slot. If a player was never in that slot, then it'll be blank. Remember that the $name variable does not read the network struct, but the player struct, which isn't updated until after EVENT_PREJOIN.

 

I'm not sure about the benefits of putting safe_read and safe_write in the reading and writing functions, because this can break things severely. SAPP's reading and writing functions let you turn safe_read and safe_write on BEFORE using them. Since you use safe_read(false) and safe_write(false) at the end of the functions, then safe reading and writing is turned off every time you use read_writestring and write_widestring, respectively. If I'm trying to write to any instructions immediately afterwards and forgot that write_widestring turns off safe_write, then the server will crash. You should do what SAPP does and leave it up to the scripter whether or not to have these turned on, rather than fight against the scripter and turn them off every time the scripter uses your functions.

NeX likes this

Share this post


Link to post
Share on other sites

A few issues:

 

You forgot OnScriptUnload(), which will cause an error to occur every time the script is unloaded. It doesn't break anything, nor will it be noticeable by many people, but it's noticeable to me, which is why I put that here. A simple "OnScriptUnload() end" put at the end of the script is enough if you're not going to use it.

 

Also, OnNameRequest()'s Name variable is actually the name of the last player to take that player slot, rather than the player's actual name, meaning that if a new player joins, they will have the name of the previous player who was in that slot. If a player was never in that slot, then it'll be blank. Remember that the $name variable does not read the network struct, but the player struct, which isn't updated until after EVENT_PREJOIN.

 

I'm not sure about the benefits of putting safe_read and safe_write in the reading and writing functions, because this can break things severely. SAPP's reading and writing functions let you turn safe_read and safe_write on BEFORE using them. Since you use safe_read(false) and safe_write(false) at the end of the functions, then safe reading and writing is turned off every time you use read_writestring and write_widestring, respectively. If I'm trying to write to any instructions immediately afterwards and forgot that write_widestring turns off safe_write, then the server will crash. You should do what SAPP does and leave it up to the scripter whether or not to have these turned on, rather than fight against the scripter and turn them off every time the scripter uses your functions.

 

NeveI changed it to send the name instead the player index even though i never had an issue with any of that.

Also I don't know why I added safe/read_write, so I removed them now.

Share this post


Link to post
Share on other sites

NeveI changed it to send the name instead the player index even though i never had an issue with any of that.

 

Every time I join, my name is set to my player index now, and this was without modifying the script in any way.

 

You may also want to store read_widestring(client_network_struct, 12) as a variable and use this variable instead of get_var when checking if the names are different. Using get_var(PlayerIndex,"$name") can cause the if/then statement to still trigger even if the name hasn't been changed through OnNameRequest depending on the name of the last player who took that slot.

Share this post


Link to post
Share on other sites

Every time I join, my name is set to my player index now, and this was without modifying the script in any way.

 

You may also want to store read_widestring(client_network_struct, 12) as a variable and use this variable instead of get_var when checking if the names are different. Using get_var(PlayerIndex,"$name") can cause the if/then statement to still trigger even if the name hasn't been changed through OnNameRequest depending on the name of the last player who took that slot.

 

Yep, fixed.

Edit: Woops! Updated read_widestring sending back un-needed blank strings.

Edited by Devieth

Share this post


Link to post
Share on other sites
Sign in to follow this  
Followers 0
  • Recently Browsing   0 members

    No registered users viewing this page.