AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Make code for all the Terrorist (https://forums.alliedmods.net/showthread.php?t=262055)

Chokitu 04-26-2015 22:00

Make code for all the Terrorist
 
How can I make this work like this
If admin type !trak
All the T's gets Ak-47
If Admin type !ctm4
All the Ct's gets m4


Code:

#include <sourcemod>
#include <sdktools_functions>

public Plugin:myinfo = {
        name = "TRAK",
        author = "Chokitu",
        description = "1.0",
        version = "1.0",
        url =""
        };
       
        public OnPluginStart()
        {
        RegAdminCmd("sm_trak", Trak, ADMFLAG_SLAY);
        RegAdminCmd("sm_ctm4", Ctm4, ADMFLAG_SLAY);
        }
       
        public Action:Trak(client, args)
        {
        GivePlayerItem(client, "weapon_ak47");
        }
       
                public Action:Ctm4(client, args)
        {
        GivePlayerItem(client, "weapon_m4a4");
        }


RedSword 04-26-2015 23:17

Re: Make code for all the Terrorist
 
Code:

#include <sdktools_functions>

public Plugin:myinfo = {
        name = "TRAK",
        author = "Chokitu",
        description = "1.0",
        version = "1.0",
        url =""
};
       
public OnPluginStart()
{
        RegAdminCmd("sm_trak", Trak, ADMFLAG_SLAY);
        RegAdminCmd("sm_ctm4", Ctm4, ADMFLAG_SLAY);
}
       
public Action:Trak(client, args)
{
        for ( new i = 1; i <= MaxClients; ++i )
                if ( IsClientInGame( i ) && GetClientTeam( i ) == 2 )
                        GivePlayerItem(i, "weapon_ak47");
}
       
public Action:Ctm4(client, args)
{
        for ( new i = 1; i <= MaxClients; ++i )
                if ( IsClientInGame( i ) && GetClientTeam( i ) == 3 )
                        GivePlayerItem(i, "weapon_m4a4");
}


BAILANDO 04-27-2015 07:32

Re: Make code for all the Terrorist
 
If you need this commands to give this weapon to all player and you need to discard actual weapon which player have, then you can use this code. I dont test it, but can works.

Code:
#include <sourcemod> #include <sdktools> #include <cstrike> //#include <sdkhooks> //#include <smlib> //#include <account> public Plugin:myinfo = {     name = "[CSS] Weapon Give with command",     author = "BAILANDO",     description = "[CSS] Weapon Give with command",     version = "1.0",     url = "http://www.urnaweb.cz" }; public OnPluginStart() {     RegAdminCmd("sm_ctm4", GiveM4ToCts, ADMFLAG_SLAY);     RegAdminCmd("sm_trak", GiveAkToTs, ADMFLAG_SLAY); } public OnMapStart() {     } public OnMapEnd() {     } public Action:GiveM4ToCts(id, args) {     new ent;     for (new i = 1; i <= MaxClients; i++) {         if (IsClientInGame(i) && GetClientTeam(i) == CS_TEAM_CT) {             if (GetPlayerWeaponSlot(i, CS_SLOT_PRIMARY) != -1) {                 ent = GetPlayerWeaponSlot(i, CS_SLOT_PRIMARY);                 RemovePlayerItem(i, ent);                 GivePlayerItem(i, "weapon_m4a1");             }         }     } } public Action:GiveAkToTs(id, args) {     new ent;     for (new i = 1; i <= MaxClients; i++) {         if (IsClientInGame(i) && GetClientTeam(i) == CS_TEAM_T) {             if (GetPlayerWeaponSlot(i, CS_SLOT_PRIMARY) != -1) {                 ent = GetPlayerWeaponSlot(i, CS_SLOT_PRIMARY);                 RemovePlayerItem(i, ent);                 GivePlayerItem(i, "weapon_ak47");             }         }     } }

Chokitu 04-27-2015 08:10

Re: Make code for all the Terrorist
 
Yes I forgot to close I did yesterday by myself but thank you

bl4nk 04-28-2015 00:04

Re: Make code for all the Terrorist
 
Quote:

Originally Posted by BAILANDO (Post 2290711)
If you need this commands to give this weapon to all player and you need to discard actual weapon which player have, then you can use this code. I dont test it, but can works.

That code will only give a player a weapon if they have one in their primary slot already. Move the GivePlayerItem call outside of that if statement. Also, why call GetPlayerWeaponSlot twice? Just save the value when you call it the first time. You should also check to see if a player is alive. I'm pretty sure if you give a weapon to a spectator, it will just spawn in the air and drop to the ground.

BAILANDO 04-28-2015 03:19

Re: Make code for all the Terrorist
 
yea, see, forgot to make else and spawn weapon for player who dont have primary.


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

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