AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Give item to last CT (https://forums.alliedmods.net/showthread.php?t=193996)

danielo_o 08-24-2012 11:39

Give item to last CT
 
Can you post your ideas?
I tried many ways, but my server is crashing.
I wanna give an AK47 to the last CT.

Napoleon_be 08-24-2012 11:48

Re: Give item to last CT
 
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

danielo_o 08-24-2012 12:00

Re: Give item to last CT
 
Can't you post the full code?
I tried myself alot of ways.

Liverwiz 08-24-2012 12:12

Re: Give item to last CT
 
Post your code and we'll correct.

Napoleon_be 08-24-2012 12:41

Re: Give item to last CT
 
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")
        }
    }



mottzi 08-24-2012 12:58

Re: Give item to last CT
 
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")
        }
    }


:arrow:
PHP Code:

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



meTaLiCroSS 08-24-2012 13:45

Re: Give item to last CT
 
Quote:

Originally Posted by mottzi (Post 1781510)
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")
        }
    }


:arrow:
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? :D

mottzi 08-24-2012 14:18

Re: Give item to last CT
 
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"



meTaLiCroSS 08-24-2012 14:33

Re: Give item to last CT
 
Quote:

Originally Posted by mottzi (Post 1781564)
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?

Alekkkk 08-24-2012 16:54

Re: Give item to last CT
 
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" )    
    }




All times are GMT -4. The time now is 05:53.

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