Get random player
I need a way to get a random players ID in the game, set it to a variable, then set another variable to that players name. Thanks!
|
new player = random_num(1,32)
then make an if statement to check if its a valid ent/player. If it isn't then just run the same line again. |
Votorx is certainly correct.
But if you'd like a more complete example of doing all you said: Getting the random player ID in variable named player Code:
And then to get the player's name based on that random player id Code:
And now the variable called "name" will have the randomly selected player's name in it. Hope this has helped. [edit]Ah, yes you are right Bailopan. Using maxplayers would be more efficient. Changed the code.[/edit] |
maybe you should go from 1 to maxplayers instead of 1 to 32
|
Thank you so much guys!
|
Im put your code into my plugin and ran the compiler, and it said Internal Error and gave the windows Not Responding window. Do you think it could have anything to do with the plugin?
|
Unload the plugin from the hlds and run the hlds again. If no error comes up then yes it is your plugin.
|
no its not the server that crashes, its the compiler when i try and compile the .sma to .amxx
|
Oh well then yes it is your plugin
|
| All times are GMT -4. The time now is 17:25. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.