Raised This Month: $ Target: $400
 0% 

Get random spawn coordinates


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 09-23-2015 , 08:42   Get random spawn coordinates
Reply With Quote #1

I'm trying to make a function which will teleport the player to a random spawn location.

PHP Code:
public teleport_to_spawn(id)
{
    new 
Float:origin[3], entity
    entity 
find_ent_by_class(random_num(-110), get_user_team(id) == "info_player_deathmatch" "info_player_start")
    
entity_get_vector(entityEV_VEC_originorigin)
    
set_user_origin(idorigin)

This doesn't work. It teleports the player outside the map.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 09-24-2015 , 07:20   Re: Get random spawn coordinates
Reply With Quote #2

try
entity_set_vector(id, EV_VEC_origin, origin)
jimaway is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 09-24-2015 , 07:56   Re: Get random spawn coordinates
Reply With Quote #3

It's working now. Thank you! Only one problem - it keeps teleporting me to the same spawn point, although I made it with random_num(-1, 10), so shouldn't it cycle through 12 different ones?

Last edited by OciXCrom; 09-24-2015 at 07:57.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
ish12321
Veteran Member
Join Date: May 2016
Old 12-29-2016 , 17:56   Re: Get random spawn coordinates
Reply With Quote #4

Quote:
Originally Posted by OciXCrom View Post
It's working now. Thank you! Only one problem - it keeps teleporting me to the same spawn point, although I made it with random_num(-1, 10), so shouldn't it cycle through 12 different ones?
Bump
__________________
['O|s|G'] | Death Wins a.k.a Ish Chhabra was here
ish12321 is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 12-29-2016 , 19:48   Re: Get random spawn coordinates
Reply With Quote #5

try this: https://forums.alliedmods.net/showthread.php?t=132500
__________________
Project: Among Us
Craxor is offline
Send a message via ICQ to Craxor
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 12-29-2016 , 20:42   Re: Get random spawn coordinates
Reply With Quote #6

Loop through all spawn points in plugin_init and store them in an array, then when you want to teleport the player, simply take a random spawn point from the array.

Answering my own question like a boss.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
ish12321
Veteran Member
Join Date: May 2016
Old 12-30-2016 , 01:37   Re: Get random spawn coordinates
Reply With Quote #7

Quote:
Originally Posted by OciXCrom View Post
Loop through all spawn points in plugin_init and store them in an array, then when you want to teleport the player, simply take a random spawn point from the array.

Answering my own question like a boss.
Small Example ?
How to get all spawn points ?
__________________
['O|s|G'] | Death Wins a.k.a Ish Chhabra was here
ish12321 is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 12-30-2016 , 08:30   Re: Get random spawn coordinates
Reply With Quote #8

https://forums.alliedmods.net/showpo...51&postcount=6
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
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 22:11.


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