Raised This Month: $12 Target: $400
 3% 

deathmatch (5 minutes =ak, 10 minutes = awp, 15 minutes = usp)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
folubek
Member
Join Date: Jan 2018
Old 05-07-2018 , 15:14   deathmatch (5 minutes =ak, 10 minutes = awp, 15 minutes = usp)
Reply With Quote #1

hi, i looking for a plugin whose can add deatchmatch (ex. 0-5 minut = only AK, 5-10 = Only AWP, 10-15 = only usp)
folubek is offline
Markiez
Junior Member
Join Date: Mar 2018
Location: somewhere over the rainb
Old 05-10-2018 , 13:12   Re: deathmatch (5 minutes =ak, 10 minutes = awp, 15 minutes = usp)
Reply With Quote #2

for example. 5 * 60 = 300, create a timer on 300 sec. make a callback function, exec a config which allows the prefered weapons. done.
__________________
bool am_I_retarded = true;
Markiez is offline
LenHard
Senior Member
Join Date: Jan 2016
Old 05-15-2018 , 04:32   Re: deathmatch (5 minutes =ak, 10 minutes = awp, 15 minutes = usp)
Reply With Quote #3

Quote:
Originally Posted by folubek View Post
hi, i looking for a plugin whose can add deatchmatch (ex. 0-5 minut = only AK, 5-10 = Only AWP, 10-15 = only usp)
PHP Code:
#include <sourcemod>
#include <sdkhooks>

#pragma semicolon 1
#pragma newdecls required

int gI_Weapon 0;

public 
void OnMapStart()
{
    
gI_Weapon 0;
    
CreateTimer(300.0Timer_RepeatINVALID_HANDLETIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);    
}

public 
void OnClientPutInServer(int client)
{
    if (!
IsFakeClient(client)) {
        
SDKHook(clientSDKHook_WeaponCanUseOnWeaponDecideUse);
    }
}

public 
Action Timer_Repeat(Handle hTimer)
{
    ++
gI_Weapon;
}

public 
Action OnWeaponDecideUse(int clientint iWeapon)
{
    if (
IsValidEdict(iWeapon) && IsClientInGame(client))
    {
        
char[] sWeapon = new char[32];
        
GetEdictClassname(iWeaponsWeapon32);
        
        switch (
gI_Weapon)
        {
            case 
1// Ak only
            
{
                if (
sWeapon[7] != 'a' && sWeapon[8] != 'k')
                    return 
Plugin_Handled;
            }
            case 
2// Next weapon
            
{
                
// etc...    
            
}
        }
    }
    return 
Plugin_Continue;

This is what you requested?
__________________
LenHard is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 05-15-2018 , 07:53   Re: deathmatch (5 minutes =ak, 10 minutes = awp, 15 minutes = usp)
Reply With Quote #4

Quote:
Originally Posted by LenHard View Post
PHP Code:
#include <sourcemod>
#include <sdkhooks>

#pragma semicolon 1
#pragma newdecls required

int gI_Weapon 0;

public 
void OnMapStart()
{
    
gI_Weapon 0;
    
CreateTimer(300.0Timer_RepeatINVALID_HANDLETIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);    
}

public 
void OnClientPutInServer(int client)
{
    if (!
IsFakeClient(client)) {
        
SDKHook(clientSDKHook_WeaponCanUseOnWeaponDecideUse);
    }
}

public 
Action Timer_Repeat(Handle hTimer)
{
    ++
gI_Weapon;
}

public 
Action OnWeaponDecideUse(int clientint iWeapon)
{
    if (
IsValidEdict(iWeapon) && IsClientInGame(client))
    {
        
char[] sWeapon = new char[32];
        
GetEdictClassname(iWeaponsWeapon32);
        
        switch (
gI_Weapon)
        {
            case 
1// Ak only
            
{
                if (
sWeapon[7] != 'a' && sWeapon[8] != 'k')
                    return 
Plugin_Handled;
            }
            case 
2// Next weapon
            
{
                
// etc...    
            
}
        }
    }
    return 
Plugin_Continue;

This is what you requested?
You have the right idea but I see a lot of things wrong with your code.

Here are some notes about your code that you should take in:

1. If you're not passing any data on a timer handle, you don't need to put "INVALID_HANDLE" in there. Just simply use an underscore like this: CreateTimer(1.0, Timer_Callback, _, TIMER_REPEAT);
2. ++i is equivalent to i + 2. You should be using i++ instead.
3. Change the following:

PHP Code:
char[] sWeapon = new char[32];
GetEdictClassname(iWeaponsWeapon32); 
To the following:

PHP Code:
char sWeapon[32];
GetEdictClassname(iWeaponsWeaponsizeof(sWeapon)); 
4. You already assigned "g_iWeapon" to 0 in your global declaration. No need to do it again on OnMapStart(). Also, simply declaring it as "int g_iWeapon;" is basically saying that it's already 0.
5. You can make the following a lot easier by changing it from:

PHP Code:
if (sWeapon[7] != 'a' && sWeapon[8] != 'k'
To the following:

PHP Code:
if (StrContains(sWeapon"ak47"false) != -1
Here's my revision:

PHP Code:
#include <sourcemod>
#include <sdkhooks>
#pragma semicolon 1
#pragma newdecls required

int g_iWeapon;

public 
void OnMapStart()
{
    
g_iWeapon 0;
    
CreateTimer(300.0TimerChangeWeapon_TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);    
}

public 
void OnClientPutInServer(int client)
{
    if (
IsValidClient(client))
    {
        
SDKHook(clientSDKHook_WeaponCanUseOnWeaponUse);
    }
}

public 
Action TimerChangeWeapon(Handle timer)
{
    
g_iWeapon++;
}

public 
Action OnWeaponUse(int clientint weapon)
{
    if (
IsValidClient(client))
    {
        
char sWeapon[32];
        
GetEdictClassname(weaponsWeaponsizeof(sWeapon));
        switch (
g_iWeapon)
        {
            case 
1// Ak only
            
{
                if (
StrContains(sWeapon"ak47"false) != -1)
                {
                    return 
Plugin_Handled;
                }
            }
            case 
2// Next weapon
            
{
                
// etc...    
            
}
        }
    }
    return 
Plugin_Continue;
}

stock bool IsValidClient(int client)
{
    return (
client && client <= MaxClients && IsClientInGame(client) && !IsClientInKickQueue(client) && IsPlayerAlive(client) && !IsFakeClient(client));

__________________
Psyk0tik is offline
LenHard
Senior Member
Join Date: Jan 2016
Old 05-15-2018 , 18:34   Re: deathmatch (5 minutes =ak, 10 minutes = awp, 15 minutes = usp)
Reply With Quote #5

Quote:
Originally Posted by Crasher_3637 View Post
You have the right idea but I see a lot of things wrong with your code.

Here are some notes about your code that you should take in:

1. If you're not passing any data on a timer handle, you don't need to put "INVALID_HANDLE" in there. Just simply use an underscore like this: CreateTimer(1.0, Timer_Callback, _, TIMER_REPEAT);
2. ++i is equivalent to i + 2. You should be using i++ instead.
3. Change the following:

PHP Code:
char[] sWeapon = new char[32];
GetEdictClassname(iWeaponsWeapon32); 
To the following:

PHP Code:
char sWeapon[32];
GetEdictClassname(iWeaponsWeaponsizeof(sWeapon)); 
4. You already assigned "g_iWeapon" to 0 in your global declaration. No need to do it again on OnMapStart(). Also, simply declaring it as "int g_iWeapon;" is basically saying that it's already 0.
5. You can make the following a lot easier by changing it from:

PHP Code:
if (sWeapon[7] != 'a' && sWeapon[8] != 'k'
To the following:

PHP Code:
if (StrContains(sWeapon"ak47"false) != -1
1. Would it change anything?
2. I tested it, and the output is the same as i++ (what it's doing is incrementing by 1 + i rather than i + 1)
3. I don't see the need for that? It functions the same way
4. I thought global variables wouldn't reset on map starts?
5. My way is more efficient but I can see why.
__________________
LenHard is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 05-15-2018 , 19:03   Re: deathmatch (5 minutes =ak, 10 minutes = awp, 15 minutes = usp)
Reply With Quote #6

Quote:
Originally Posted by LenHard View Post
1. Would it change anything?
2. I tested it, and the output is the same as i++ (what it's doing is incrementing by 1 + i rather than i + 1)
3. I don't see the need for that? It functions the same way
4. I thought global variables wouldn't reset on map starts?
5. My way is more efficient but I can see why.
1 and 3. Makes it shorter, but that's up to you.
2. My bad on that one. You didn't change the value of g_iWeapon before doing ++g_iWeapon so it still uses the initial value, so there's no problem with that one.
4. They don't. I'm just saying that you don't need to assign it to 0 as a global while also assigning as 0 on OnMapStart(). Again it's up to you, nothing bad.
5. While your way may be more efficient, it would make more sense to just check if the weapon has "ak47" in it. You could also use StrEqual to just check for "weapon_ak47".
__________________
Psyk0tik is offline
weez
Junior Member
Join Date: Jul 2014
Old 05-13-2020 , 07:45   Re: deathmatch (5 minutes =ak, 10 minutes = awp, 15 minutes = usp)
Reply With Quote #7

How can i replace ak47 with pistols ?
I want to make first 10 minutes pistol , 10 minutes rifles and 10 minutes awp
__________________
weez is offline
XHUNTERX
Senior Member
Join Date: Aug 2019
Location: World
Old 05-15-2020 , 11:03   Re: deathmatch (5 minutes =ak, 10 minutes = awp, 15 minutes = usp)
Reply With Quote #8

it's better to add an editable version
XHUNTERX is offline
Ejziponken
AlliedModders Donor
Join Date: Apr 2008
Old 05-15-2020 , 11:22   Re: deathmatch (5 minutes =ak, 10 minutes = awp, 15 minutes = usp)
Reply With Quote #9

This works with Deathmatch Advanced. Add the times and mode names from deathmatch.ini (not simple).


Code:
#pragma semicolon 1

#define DEBUG
#include <sourcemod>

public void OnMapStart()
{
    CreateTimer(300.0, Timer_Callback, _, TIMER_FLAG_NO_MAPCHANGE);
}

chosen = 0;

public Action Timer_Callback(Handle timer)
{

    if(chosen == 0)
        ServerCommand("dm_load \"Game Modes\" \"Ak Colt\" equip");
        CreateTimer(INSERTSECONDSHERE.0, Timer_Callback, _, TIMER_FLAG_NO_MAPCHANGE);
    else if(chosen == 1)
        ServerCommand("dm_load \"Game Modes\" \"Pistols\" equip");
        CreateTimer(INSERTSECONDSHERE.0, Timer_Callback, _, TIMER_FLAG_NO_MAPCHANGE);
    else if(chosen == 2)
        ServerCommand("dm_load \"Game Modes\" \"Scout knives\" equip");
        CreateTimer(INSERTSECONDSHERE.0, Timer_Callback, _, TIMER_FLAG_NO_MAPCHANGE);
    else if(chosen == 3)
        ServerCommand("dm_load \"Game Modes\" \"SMGs\" equip");
        CreateTimer(INSERTSECONDSHERE.0, Timer_Callback, _, TIMER_FLAG_NO_MAPCHANGE);

    if(chosen == 3)
        chosen = 0;

    chosen++;
    return Plugin_Handled;
}

Last edited by Ejziponken; 05-15-2020 at 11:23.
Ejziponken is offline
XHUNTERX
Senior Member
Join Date: Aug 2019
Location: World
Old 05-15-2020 , 11:40   Re: deathmatch (5 minutes =ak, 10 minutes = awp, 15 minutes = usp)
Reply With Quote #10

can you help me
is everything right?

Code:
#include <sourcemod>
#include <sdkhooks>
#pragma semicolon 1
#pragma newdecls required

int g_iWeapon;

public void OnMapStart()
{
    g_iWeapon = 0;
    CreateTimer(300.0, TimerChangeWeapon, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);    
}

public void OnClientPutInServer(int client)
{
    if (IsValidClient(client))
    {
        SDKHook(client, SDKHook_WeaponCanUse, OnWeaponUse);
    }
}

public Action TimerChangeWeapon(Handle timer)
{
    g_iWeapon++;
}

public Action OnWeaponUse(int client, int weapon)
{
    if (IsValidClient(client))
    {
        char sWeapon[32];
        GetEdictClassname(weapon, sWeapon, sizeof(sWeapon));
        switch (g_iWeapon)
        {
            case 1: // USP-S
            {
                if (StrContains(sWeapon, "usp_silencer", false) != -1)
                {
                    return Plugin_Handled;
                }
            }
            case 2: // DEAGLE
            {
                if (StrContains(sWeapon, "deagle", false) != -1)
                {
                    return Plugin_Handled;
                }
            }
            case 3: // AK47
            {
                if (StrContains(sWeapon, "ak47", false) != -1)
                {
                    return Plugin_Handled;
                }
            }
            case 4: // M4A1
            {
                if (StrContains(sWeapon, "m4a1", false) != -1)
                {
                    return Plugin_Handled;
                }
            }
            case 5: // SSG
            {
                if (StrContains(sWeapon, "ssg08", false) != -1)
                {
                    return Plugin_Handled;
                }
            }
            case 6: // AWP
            {
                if (StrContains(sWeapon, "awp", false) != -1)
                {
                    return Plugin_Handled;
                }
            }
        }
    }
    return Plugin_Continue;
}

stock bool IsValidClient(int client)
{
    return (client > 0 && client <= MaxClients && IsClientInGame(client) && !IsClientInKickQueue(client) && IsPlayerAlive(client) && !IsFakeClient(client));
}

Last edited by XHUNTERX; 05-15-2020 at 11:41.
XHUNTERX is offline
Reply


Thread Tools
Display Modes

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


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