AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Solved]Exchange T and CT Spawn on Round Start (https://forums.alliedmods.net/showthread.php?t=226655)

devilicioux 09-21-2013 09:30

[Solved]Exchange T and CT Spawn on Round Start
 
Code Still has Bugs .. Uploaded back before i fixed them On special request by Hornet :P I dont think now this is required in New plugin submissions. So fix the bugs and use it :D Here you go.

PHP Code:

#include <amxmodx> 
#include <fun>
#include <engine>

new g_playerT,g_playerCT;
new 
g_maxplayers

public plugin_init() 
{               
register_event("HLTV""event_NewRound""a""1=0""2=0");             
register_event"DeathMsg""EventDeathMsg""a""1>0" );
g_maxplayers get_maxplayers()    


public 
event_NewRound() {         
//client_print(g_playerCT, print_chat, "Delaying 2 seconds");
set_task(2.0,"spawnplayers")   


public 
EventDeathMsg() {
new 
killer read_data(1);
new 
victim read_data(2);
if ( 
g_playerT && victim == g_playerT && is_user_connected(killer) ) {                 
new 
killer_name[32], victim_name[32];                 
get_user_name(killerkiller_namecharsmax(killer_name));         
get_user_name(victimvictim_namecharsmax(victim_name));                 
colored_print(0"^x04 %s saved the Asses of Ts by killing %s and was given 50HP Bonus :D"killer_name,victim_name);
show_hudmessage(killer ,"Bonus +50 HP[Deathmsg]");
set_user_health(killerget_user_health(killer) + 50);


if ( 
g_playerCT && victim == g_playerCT && is_user_connected(killer) ) {                 
new 
killer_name[32], victim_name[32];                 
get_user_name(killerkiller_namecharsmax(killer_name));         
get_user_name(victimvictim_namecharsmax(victim_name));                 
colored_print(0"^x04 %s saved the Asses of Ts by killing %s and was given 50HP Bonus :D"killer_name,victim_name);
show_hudmessage(killer ,"Bonus +50 HP[Deathmsg]");
set_user_health(killerget_user_health(killer) + 50);
}
}

public 
client_disconnect(id) {     
if ( 
id == g_playerT )         
g_playerT 0

if ( 
id == g_playerCT )         
g_playerCT 0



public 
spawnplayers()
{
if ( 
g_playerT ) {
//colored_print(g_playerT, "Saale Bach kaise gya xD !!")        
//client_print(g_playerT, print_chat, "Phew.. You have survived the round !!");           
}         
if ( 
g_playerCT ) {        
//colored_print(g_playerCT, "Saale Bach kaise gya xD !!")
//client_print(g_playerCT, print_chat, "Phew ..You have survived the round !!");           


g_playerT 0;
g_playerCT 0;

new 
playersT[32], playersnumT;     
new 
playersCT[32], playersnumCT

get_players(playersTplayersnumT"a""TERRORIST");
get_players(playersCTplayersnumCT"a""CT");

g_playerT playersT[random(playersnumT)];  
   
g_playerCT playersCT[random(playersnumCT)];      

new 
nameT[32],nameCT[32];     
get_user_name(g_playerTnameTcharsmax(nameT));   
get_user_name(g_playerCTnameCTcharsmax(nameCT));     

//client_print(g_playerCT, print_chat, "Players chosen");

new Tspot[33][3]
new 
CTspot[33][3]

//Get Spawn
get_user_origin(g_playerT,Tspot[g_playerT])
get_user_origin(g_playerCT,CTspot[g_playerCT])

//client_print(0, print_chat, "Spawns GET!");

//Set Spawn
set_user_origin(g_playerT,CTspot[g_playerCT])
set_user_origin(g_playerCT,Tspot[g_playerT])

//client_print(0, print_chat, "Spawns SET!");
set_user_health(g_playerTget_user_health(g_playerT) + 100);
set_user_health(g_playerCTget_user_health(g_playerCT) + 100);
//Done Spawning
colored_print(0"^x04Spawns of %s & %s are exchanged :D Kill Or Get Killed!"nameTnameCT); 
}

/*
public event_HamKilled(victim, killer) 

set_hudmessage(127, 170, 255, 0.27, 0.14, 0, 5.0, 5.0, 0.0, 0.0, -1);
    
if ( g_playerT && victim == g_playerT && is_user_connected(killer) ) {                 
new killer_name[32], victim_name[32];                 
get_user_name(killer, killer_name, charsmax(killer_name));         
get_user_name(victim, victim_name, charsmax(victim_name));                 
colored_print(0, "^x04 %s saved the Asses of CTs by killing %s and was given 50HP Bonus :D[HAM]", killer_name,victim_name);
show_hudmessage(killer ,"Bonus +50 HP[HAM]");
set_user_health(killer, get_user_health(killer) + 50);


if ( g_playerCT && victim == g_playerCT && is_user_connected(killer) ) {                 
new killer_name[32], victim_name[32];                 
get_user_name(killer, killer_name, charsmax(killer_name));         
get_user_name(victim, victim_name, charsmax(victim_name));                 
colored_print(0, "^x04 %s saved the Asses of Ts by killing %s and was given 50HP Bonus :D[HAM]", killer_name,victim_name);
show_hudmessage(killer ,"Bonus +50 HP[HAM]");
set_user_health(killer, get_user_health(killer) + 50);
}
}
*/

// Colored print by MeRcyLeZZ
colored_print(target, const message[], any:...)
{
    static 
buffer[512], iargscountg_msgSayText
    argscount 
numargs()
    
g_msgSayText get_user_msgid("SayText")
    
    
// Send to everyone
    
if (!target)
    {
        static 
player
        
for (player 1player <= g_maxplayersplayer++)
        {
            
// Not connected
            
if (!is_user_connected(player))
                continue;
            
            
// Remember changed arguments
            
static changed[5], changedcount // [5] = max LANG_PLAYER occurencies
            
changedcount 0
            
            
// Replace LANG_PLAYER with player id
            
for (2argscounti++)
            {
                if (
getarg(i) == LANG_PLAYER)
                {
                    
setarg(i0player)
                    
changed[changedcount] = i
                    changedcount
++
                }
            }
            
            
// Format message for player
            
vformat(buffercharsmax(buffer), message3)
            
            
// Send it
            
message_begin(MSG_ONE_UNRELIABLEg_msgSayText_player)
            
write_byte(player)
            
write_string(buffer)
            
message_end()
            
            
// Replace back player id's with LANG_PLAYER
            
for (0changedcounti++)
                
setarg(changed[i], 0LANG_PLAYER)
        }
    }
    
// Send to specific target
    
else
    {
        
// Format message for player
        
vformat(buffercharsmax(buffer), message3)
        
        
// Send it
        
message_begin(MSG_ONEg_msgSayText_target)
        
write_byte(target)
        
write_string(buffer)
        
message_end()
    }



Black Rose 09-21-2013 10:28

Re: Exchange T and CT Spawn on Round Start
 
When is the event called?

devilicioux 09-21-2013 10:45

Re: Exchange T and CT Spawn on Round Start
 
Yeah sorry missed out ..

PHP Code:

register_event("HLTV""event_NewRound""a""1=0""2=0"); 


Black Rose 09-21-2013 11:08

Re: Exchange T and CT Spawn on Round Start
 
That is called before players spawn.
Use Ham_Spawn for "player" in post

devilicioux 09-21-2013 11:16

Re: Exchange T and CT Spawn on Round Start
 
Quote:

Originally Posted by Black Rose (Post 2038497)
That is called before players spawn.
Use Ham_Spawn for "player" in post

But will the Ham_spawn be called everytime a player spawns/respawns in between round as well ? I dont understand how to use it for just 2 players Only on Round start :?:

Check these as well.. Now i am getting confused :3

Quote:

Originally Posted by minimiller (Post 854960)
HLTV hooks round start
i believe players spawn 1 server frame after that

Quote:

Originally Posted by hleV (Post 855013)
What do you mean "Ham_Spawn called in HLTV"? Ham_Spawn is called when player spawns and HLTV is called on the new round.

Usually player spawns (and Ham_Spawn is called) at about the same time when HLTV is called.

Quote:

Originally Posted by Arkshine (Post 855024)
When a new round is called players spawn right after.


Black Rose 09-21-2013 11:22

Re: Exchange T and CT Spawn on Round Start
 
Then delay it using set_task() from HLTV.

Here's the order of different functions:
Code:

event_HLTV, global
fwd_HamPlayerSpawnPre, specific
fwd_HamPlayerSpawnPost, specific
event_ResetHUD, specific
logevent_RoundStart, global


devilicioux 09-21-2013 12:21

Re: Exchange T and CT Spawn on Round Start
 
Quote:

Originally Posted by Black Rose (Post 2038510)
Then delay it using set_task() from HLTV.

Here's the order of different functions:
Code:

event_HLTV, global
fwd_HamPlayerSpawnPre, specific
fwd_HamPlayerSpawnPost, specific
event_ResetHUD, specific
logevent_RoundStart, global



Thanks it worked :) 1 second delay did the work perfectly :)

wickedd 09-22-2013 08:20

Re: [Solved]Exchange T and CT Spawn on Round Start
 
Quote:

Originally Posted by devilicioux (Post 2038453)
Trash this Please.

Why did you edit your post?

hornet 09-22-2013 08:47

Re: [Solved]Exchange T and CT Spawn on Round Start
 
Quote:

Originally Posted by wickedd (Post 2039026)
Why did you edit your post?

Quote:

Last edited by devilicioux; Today at 02:24 AM. Reason: Will release the plugin as in New plugin Submissions :)
Releasing a plugin that other users just put together for you ... Sounds convincing ...

devilicioux 09-26-2013 06:05

Re: [Solved]Exchange T and CT Spawn on Round Start
 
Quote:

Originally Posted by hornet (Post 2039038)
Releasing a plugin that other users just put together for you ... Sounds convincing ...

Have a look at the complete post before you say that. I dont see any codes/help from USER"S" except Black Rose .. where did that USERS come from Mr. Hornet ?
+ You should have a problem when i am going to make the plugin private on which people helped me instead i am going to release it in new plugin .. Does that create a problem ?


All times are GMT -4. The time now is 18:50.

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