AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Get random spawn coordinates (https://forums.alliedmods.net/showthread.php?t=272062)

OciXCrom 09-23-2015 08:42

Get random spawn coordinates
 
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.

jimaway 09-24-2015 07:20

Re: Get random spawn coordinates
 
try
entity_set_vector(id, EV_VEC_origin, origin)

OciXCrom 09-24-2015 07:56

Re: Get random spawn coordinates
 
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?

ish12321 12-29-2016 17:56

Re: Get random spawn coordinates
 
Quote:

Originally Posted by OciXCrom (Post 2346452)
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

Craxor 12-29-2016 19:48

Re: Get random spawn coordinates
 
try this: https://forums.alliedmods.net/showthread.php?t=132500

OciXCrom 12-29-2016 20:42

Re: Get random spawn coordinates
 
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.

ish12321 12-30-2016 01:37

Re: Get random spawn coordinates
 
Quote:

Originally Posted by OciXCrom (Post 2481821)
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 ?

OciXCrom 12-30-2016 08:30

Re: Get random spawn coordinates
 
https://forums.alliedmods.net/showpo...51&postcount=6


All times are GMT -4. The time now is 22:11.

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