Raised This Month: $ Target: $400
 0% 

Give item to last CT


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
danielo_o
Member
Join Date: Mar 2011
Old 08-24-2012 , 11:39   Give item to last CT
Reply With Quote #1

Can you post your ideas?
I tried many ways, but my server is crashing.
I wanna give an AK47 to the last CT.
danielo_o is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 08-24-2012 , 11:48   Re: Give item to last CT
Reply With Quote #2

first the ct team players by using get_players()
after then loop trough them and check if there is only 1 ct left and give him the ak47
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
danielo_o
Member
Join Date: Mar 2011
Old 08-24-2012 , 12:00   Re: Give item to last CT
Reply With Quote #3

Can't you post the full code?
I tried myself alot of ways.
danielo_o is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 08-24-2012 , 12:12   Re: Give item to last CT
Reply With Quote #4

Post your code and we'll correct.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 08-24-2012 , 12:41   Re: Give item to last CT
Reply With Quote #5

UNTESTED & SHOULD WORK

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <fun>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /giveak47""CmdGiveWeapon")
}

public 
CmdGiveWeapon(id) {
    new 
players[32], count
    get_players
(playerscount"ae""CT")
    
    for(new 
icounti++) {
        if(
count == 1) {
            
give_item(players[i], "weapon_ak47")
        }
    }

__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 08-24-2012 , 12:58   Re: Give item to last CT
Reply With Quote #6

PHP Code:
public CmdGiveWeapon(id) {
    new 
players[32], count
    get_players
(playerscount"ae""CT")
    
    for(new 
icounti++) {
        if(
count == 1) {
            
give_item(players[i], "weapon_ak47")
        }
    }


PHP Code:
public CmdGiveWeapon(id) {
    new 
players[32], count
    get_players
(playerscount"ae""CT")
  
    
give_item(players[0], "weapon_ak47")

__________________
Quote:
#define true ((rand() % 2)? true: false) //Happy debugging suckers

Last edited by mottzi; 08-24-2012 at 12:58.
mottzi is offline
Send a message via MSN to mottzi
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 08-24-2012 , 13:45   Re: Give item to last CT
Reply With Quote #7

Quote:
Originally Posted by mottzi View Post
PHP Code:
public CmdGiveWeapon(id) {
    new 
players[32], count
    get_players
(playerscount"ae""CT")
    
    for(new 
icounti++) {
        if(
count == 1) {
            
give_item(players[i], "weapon_ak47")
        }
    }


PHP Code:
public CmdGiveWeapon(id) {
    new 
players[32], count
    get_players
(playerscount"ae""CT")
  
    
give_item(players[0], "weapon_ak47")

What about if there are no CT? players[0] would be 0, and an error would be send. Did you think on it?
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 08-24-2012 , 14:18   Re: Give item to last CT
Reply With Quote #8

right but the threadcreator hopefully has a brain so he could get that on his own. I just wanted to show that a loop isnt necessary in this case.

PHP Code:
public CmdGiveWeapon(id) { 
    new 
players[32], count 
    get_players
(playerscount"ae""CT"
   
    if(
count == 1give_item(players[0], "weapon_ak47"

__________________
Quote:
#define true ((rand() % 2)? true: false) //Happy debugging suckers

Last edited by mottzi; 08-24-2012 at 17:57.
mottzi is offline
Send a message via MSN to mottzi
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 08-24-2012 , 14:33   Re: Give item to last CT
Reply With Quote #9

Quote:
Originally Posted by mottzi View Post
right but the threadcreator hopefully has a brain so he could get that on his own. I just wanted to show that a loop isnt necessary in this case.

PHP Code:
public CmdGiveWeapon(id) { 
    new 
players[32], count 
    get_players
(playerscount"ae""CT"
   
    if(
count 0give_item(players[0], "weapon_ak47"

There can be more than 4 CTs and the first one listed would get the weapon... again, did you think on it?
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
Alekkkk
Member
Join Date: Mar 2012
Location: Bulgaria
Old 08-24-2012 , 16:54   Re: Give item to last CT
Reply With Quote #10

something like this ?

PHP Code:
#include <amxmodx>
#include <cstrike>
#include <hamsandwich>
#include <fun>

#define PLUGIN ""
#define VERSION ""
#define AUTHOR ""


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
RegisterHamHam_Killed"player""PlayerKilled" )
}
public 
PlayerKilledvictim )
{
    if( 
cs_get_user_teamvictim ) == CS_TEAM_CT )
    {
        new 
players32 ], count
        get_players
playerscount"ae""CT" );
        
        if( 
count == )
            
give_itemplayers[0], "weapon_ak47" )    
    }

__________________

Last edited by Alekkkk; 08-24-2012 at 16:54.
Alekkkk is offline
Send a message via Skype™ to Alekkkk
Reply



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 05:53.


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