AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Teleport to random position (https://forums.alliedmods.net/showthread.php?t=335667)

The overrated maniac 12-23-2021 07:28

Teleport to random position
 
How can I teleport a player to a random position in the map?
Dosnt matter if its on a wall or something because I can teleport him until this stock turns false

PHP Code:

stock is_player_stuck(id)
{
    static 
Float:originF[3];
    
pev(idpev_originoriginF);
    
    
engfunc(EngFunc_TraceHulloriginForiginF0, (pev(idpev_flags) & FL_DUCKING) ? HULL_HEAD HULL_HUMANid0);
    
    if (
get_tr2(0TR_StartSolid) || get_tr2(0TR_AllSolid) || !get_tr2(0TR_InOpen))
        return 
true;
    
    return 
false;



HamletEagle 12-23-2021 09:15

Re: Teleport to random position
 
To generate random valid origins: https://forums.alliedmods.net/showthread.php?t=309495
Then, just use EngFunc_SetOrigin

The overrated maniac 12-23-2021 09:28

Re: Teleport to random position
 
Quote:

Originally Posted by HamletEagle (Post 2766764)
To generate random valid origins: https://forums.alliedmods.net/showthread.php?t=309495
Then, just use EngFunc_SetOrigin

Thanks. I dont understand your include so well. If I put
PHP Code:

new Float:Origin[3];
ROGGetOrigin(Origin);
engfunc(EngFunc_SetOriginidOrigin); 

on my function, the player will be transported? Or I need to do something before? like generate the origins with ROGInitialize(250.0)

Also, I got 2 warnings when did that:
CheckPointsForVisibility never used
NumberOfOrigins is assigned and never used

Edit: dont work
Edit2: with ROGInitialize(250.0) works, thanks :)

HamletEagle 12-23-2021 11:06

Re: Teleport to random position
 
You have an example plugin in the topic, read it. It does what you want already. But, long story short: you need to initialize the random origin generator(obviously, can't use something that was not initialized) and then you can just retrieve the next available origin and use EngFunc_SetOrigin.
Also, feel free to ignore any warning you may get.

If you tried something, show the code. Saying "it does not work" is not helpful at all. How am I supposed(or anyone else) to know what you did wrong when you don't show what you did?

The overrated maniac 12-23-2021 11:13

Re: Teleport to random position
 
Quote:

Originally Posted by HamletEagle (Post 2766769)
You have an example plugin in the topic, read it.
Also, feel free to ignore any warning you may get.

If you tried something, show the code. Saying "it does not work" is not helpful at all. How am I supposed(or anyone else) to know what you did wrong when you don't show what you did?

You dont need the whole function, what I did was the code I posted in php and it didnt work. Then added the initialize before it and worked, in your post you dont say that you have to initialize it and in the example code you also dont put it. Anyways thanks, its a really good include.

HamletEagle 12-23-2021 11:17

Re: Teleport to random position
 
Are you absolutely sure about that? I can clearly see a call to ROGInitialize in plugin_init inside the example code. You aren't supposed to initialize it every single time, just once, in plugin_init(exactly like it is shown in the example code which you didn't bother to read).

You also didn't bother to post the full code so I had no way of knowing if you had ROGInitialize in plugin_init or not.
To everyone: please comply with what is asked, we don't ask random stuff just for the sake of it. Stop making our job harder by being stubborn. If we ask you to post the entire plugin, post it, we have our reasons. Otherwise, if you insist on knowing better what is needed and what is not, just fix it by yourself.

Natsheh 12-24-2021 11:21

Re: Teleport to random position
 
Quote:

Originally Posted by HamletEagle (Post 2766771)
Are you absolutely sure about that? I can clearly see a call to ROGInitialize in plugin_init inside the example code. You aren't supposed to initialize it every single time, just once, in plugin_init(exactly like it is shown in the example code which you didn't bother to read).

You also didn't bother to post the full code so I had no way of knowing if you had ROGInitialize in plugin_init or not.
To everyone: please comply with what is asked, we don't ask random stuff just for the sake of it. Stop making our job harder by being stubborn. If we ask you to post the entire plugin, post it, we have our reasons. Otherwise, if you insist on knowing better what is needed and what is not, just fix it by yourself.

Is it possible to add a feature to seek for valid spawns inside the map, because some maps have a sky box around the whole map, which is a bad map so is there a way to workaround bad maps?

HamletEagle 12-24-2021 14:10

Re: Teleport to random position
 
I'm not sure what you are asking, the spawn points are validated as much as possible already.
If you have a certain map in mind where bad spawn points are generated, attach it.

Also, it would be better to post in the ROG topic, not here.


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

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