Raised This Month: $ Target: $400
 0% 

!Redie to spawn on Alive players


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
SkinnyBruv
AlliedModders Donor
Join Date: Feb 2013
Location: Straya
Old 11-02-2013 , 03:44   !Redie to spawn on Alive players
Reply With Quote #1

PHP Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#include <sdkhooks>

#pragma semicolon 1

#define PLUGIN_VERSION     "1.4"

new blockCommand;
new 
g_Collision;
new 
Handle:cvar_adverts INVALID_HANDLE;
new 
bool:g_IsGhost[MAXPLAYERS+1];

public 
Plugin:myinfo =
{
    
name "Redie 4 SourceMod",
    
author "MeoW",
    
description "Return as a ghost after you died.",
    
version PLUGIN_VERSION,
    
url "http://www.trident-gaming.net/"
};

public 
OnPluginStart()
{
    
HookEvent("round_end"Event_Round_EndEventHookMode_Pre);
    
HookEvent("round_start"Event_Round_StartEventHookMode_Pre);    
    
HookEvent("player_spawn"Event_Player_Spawn);
    
HookEvent("player_death"Event_Player_Death);
    
RegConsoleCmd("sm_redie"Command_Redie);
    
CreateTimer(120.0advert_,TIMER_REPEAT);
    
CreateConVar("sm_redie_version"PLUGIN_VERSION"Redie Version"FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
    
cvar_adverts CreateConVar("sm_redie_adverts""1""If enabled, redie will produce an advert every 2 minutes.");
    
g_Collision FindSendPropInfo("CBaseEntity""m_CollisionGroup");
}

public 
OnClientPutInServer(client)
{
    
SDKHook(clientSDKHook_WeaponCanUseOnWeaponCanUse);
}

public 
OnClientPostAdminCheck(client)
{
    
g_IsGhost[client] = false;
}

public 
Action:Event_Round_End(Handle:event, const String:name[], bool:dontBroadcast
{
    
blockCommand false;
}

public 
Action:Event_Round_Start(Handle:event, const String:name[], bool:dontBroadcast
{
    
blockCommand true;
}


public 
Action:Event_Player_Spawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if(
g_IsGhost[client])
    {
        
SetEntProp(clientProp_Send"m_nHitboxSet"2);
        
g_IsGhost[client] = false;
    }
    else
    {
        
SetEntProp(clientProp_Send"m_nHitboxSet"0);
    }
}

public 
Action:Event_Player_Death(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    
PrintToChat(client"\x01[\x03AGNRedie\x01] \x04Type !redie into chat to respawn as a ghost.");
}

public 
Action:OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon)
{
    if(
GetEntProp(clientProp_Send"m_lifeState") == 1)
    {
        
buttons &= ~IN_USE;
    }
    return 
Plugin_Continue;
}

public 
Action:Command_Redie(clientargs)
{
    if(
blockCommand)
    {
        if (!
IsPlayerAlive(client))
        {
            if(
GetClientTeam(client) > 1)
            {
                
g_IsGhost[client] = true;

                
CS_RespawnPlayer(client);
                
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;
                }  
                new 
weaponIndex;
                for (new 
0<= 3i++)
                {
                    if ((
weaponIndex GetPlayerWeaponSlot(clienti)) != -1)
                    {  
                        
RemovePlayerItem(clientweaponIndex);
                        
RemoveEdict(weaponIndex);
                    }
                }
                
SetEntProp(clientProp_Send"m_lifeState"1);
                
SetEntData(clientg_Collision24true);
                
PrintToChat(client"\x01[\x03Redie\x01] \x04You are now a ghost.");
            }
            else
            {
                
PrintToChat(client"\x01[\x03Redie\x01] \x04You must be on a team.");
            }
        }
        else
        {
            
PrintToChat(client"\x01[\x03Redie\x01] \x04You must be dead to use redie.");
        }
    }
    else
    {
        
PrintToChat(client"\x01[\x03Redie\x01] \x04Please wait for the new round to begin.");
    }
    return 
Plugin_Handled;


public 
Action:OnWeaponCanUse(clientweapon)
{
    if(
GetEntProp(clientProp_Send"m_lifeState") == 1)
        return 
Plugin_Handled;
    
    return 
Plugin_Continue;
}

public 
Action:advert(Handle:timer)
{
    if(
GetConVarInt(cvar_adverts))
    {
        
PrintToChatAll ("\x01[\x03AGNRedie\x01] \x04This server is running a modified version of !redie.");
    }
    return 
Plugin_Continue;

Can somebody help me fix this problem i have.

Like if you type !redie multiple times, 1 out of like 15 chances you will actually spawn on an alive player but the rest of them you actually spawn in the spawn locations.

Can someone help me fix the code.

Could we actually somehow remove the spawn locations just for redie so they only spawn on currently alive players?

Im not sure, just please comment and help out
__________________
www.ancientgaming.net is my story.
Everything happens for a reason.
Nothing is random...
#Do you even AGN...
SkinnyBruv is offline
Send a message via Skype™ to SkinnyBruv
 



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:04.


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