AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   !redie spawns on an actual player (https://forums.alliedmods.net/showthread.php?t=229025)

SkinnyBruv 10-31-2013 07:00

!redie spawns on an actual player
 
Howdy i need help recoding

http://forums.alliedmods.net/showthread.php?p=1210395 - !redie

so when you type !redie you spawn on an already alive player.
Or a menu pops up whether to spawn in spawnplace or on an alive player.


Cheers
If you know how to do it, please help

sdz 10-31-2013 16:01

Re: !redie spawns on an actual player
 
PHP Code:

//Spawn Function/Redie Function

    
decl Float:fOrigin[3];
    new 
iRandom GetRandomInt(1MaxClients);
    for(new 
1<= MaxClientsi++)
    {
        if(
== iRandom)
        {
            
GetClientAbsOrigin(ifOrigin);
            if(
IsClientInGame(Client) && IsPlayerAlive(Client) && IsClientInGame(i))
            {
                
TeleportEntity(ClientfOriginNULL_VECTORNULL_VECTOR);
                break;
            }
        }
        else break;
    } 

What does this do?

fOrigin: The buffer (variable which we store data in) for the client's angles that we're going to be spawning on.
iRandom: We're doing this to get Player 1 to Player X (Not all games/servers have same amount of max players)
for(new i = 1; i <= MaxClients: We're looping through every player and getting a random player to spawn on
if(i == iRandom): Teleport the Player to the randomly selected client
break;: Stop the loop immediatly (no inf. looping)

SkinnyBruv 10-31-2013 17:12

Re: !redie spawns on an actual player
 
Quote:

Originally Posted by EasSidezz (Post 2055236)
PHP Code:

//Spawn Function/Redie Function

    
decl Float:fOrigin[3];
    new 
iRandom GetRandomInt(1MaxClients);
    for(new 
1<= MaxClientsi++)
    {
        if(
== iRandom)
        {
            
GetClientAbsOrigin(ifOrigin);
            if(
IsClientInGame(Client) && IsPlayerAlive(Client) && IsClientInGame(i))
            {
                
TeleportEntity(ClientfOriginNULL_VECTORNULL_VECTOR);
                break;
            }
        }
        else break;
    } 

What does this do?

fOrigin: The buffer (variable which we store data in) for the client's angles that we're going to be spawning on.
iRandom: We're doing this to get Player 1 to Player X (Not all games/servers have same amount of max players)
for(new i = 1; i <= MaxClients: We're looping through every player and getting a random player to spawn on
if(i == iRandom): Teleport the Player to the randomly selected client
break;: Stop the loop immediatly (no inf. looping)

Wow thanks man,
Didnt realise it was that easy

But you gotta change some stuff


PHP Code:

    decl Float:fOrigin[3];
    new 
iRandom GetRandomInt(1MaxClients);
    for(new 
1<= MaxClientsi++)
    {
        if(
== iRandom)
        {
            
GetClientAbsOrigin(ifOrigin);
            if(
IsClientInGame(i) && IsPlayerAlive(Client) && IsClientInGame(i))
            {
                
TeleportEntity(ifOriginNULL_VECTORNULL_VECTOR);
                break;
            }
        }
        else break;
    } 



All times are GMT -4. The time now is 14:13.

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