Raised This Month: $32 Target: $400
 8% 

Solved Teleport to random position


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
The overrated maniac
Member
Join Date: Jun 2021
Location: Argentina
Old 12-23-2021 , 07:28   Teleport to random position
Reply With Quote #1

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;


Last edited by The overrated maniac; 12-23-2021 at 11:09. Reason: Solved
The overrated maniac is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-23-2021 , 09:15   Re: Teleport to random position
Reply With Quote #2

To generate random valid origins: https://forums.alliedmods.net/showthread.php?t=309495
Then, just use EngFunc_SetOrigin
__________________
HamletEagle is offline
The overrated maniac
Member
Join Date: Jun 2021
Location: Argentina
Old 12-23-2021 , 09:28   Re: Teleport to random position
Reply With Quote #3

Quote:
Originally Posted by HamletEagle View Post
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 :)

Last edited by The overrated maniac; 12-23-2021 at 11:09. Reason: Solved
The overrated maniac is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-23-2021 , 11:06   Re: Teleport to random position
Reply With Quote #4

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?
__________________

Last edited by HamletEagle; 12-23-2021 at 11:10.
HamletEagle is offline
The overrated maniac
Member
Join Date: Jun 2021
Location: Argentina
Old 12-23-2021 , 11:13   Re: Teleport to random position
Reply With Quote #5

Quote:
Originally Posted by HamletEagle View Post
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.
The overrated maniac is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-23-2021 , 11:17   Re: Teleport to random position
Reply With Quote #6

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.
__________________

Last edited by HamletEagle; 12-23-2021 at 11:20.
HamletEagle is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 12-24-2021 , 11:21   Re: Teleport to random position
Reply With Quote #7

Quote:
Originally Posted by HamletEagle View Post
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?
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-24-2021 , 14:10   Re: Teleport to random position
Reply With Quote #8

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.
__________________

Last edited by HamletEagle; 12-24-2021 at 14:11.
HamletEagle is offline
Reply


Thread Tools
Display Modes

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 01:39.


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