AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   deathmatch (5 minutes =ak, 10 minutes = awp, 15 minutes = usp) (https://forums.alliedmods.net/showthread.php?t=307386)

folubek 05-07-2018 15:14

deathmatch (5 minutes =ak, 10 minutes = awp, 15 minutes = usp)
 
hi, i looking for a plugin whose can add deatchmatch (ex. 0-5 minut = only AK, 5-10 = Only AWP, 10-15 = only usp)

Markiez 05-10-2018 13:12

Re: deathmatch (5 minutes =ak, 10 minutes = awp, 15 minutes = usp)
 
for example. 5 * 60 = 300, create a timer on 300 sec. make a callback function, exec a config which allows the prefered weapons. done.

LenHard 05-15-2018 04:32

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

Originally Posted by folubek (Post 2591172)
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?

Psyk0tik 05-15-2018 07:53

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

Originally Posted by LenHard (Post 2592235)
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));



LenHard 05-15-2018 18:34

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

Originally Posted by Crasher_3637 (Post 2592259)
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.

Psyk0tik 05-15-2018 19:03

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

Originally Posted by LenHard (Post 2592356)
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".

weez 05-13-2020 07:45

Re: deathmatch (5 minutes =ak, 10 minutes = awp, 15 minutes = usp)
 
How can i replace ak47 with pistols ?
I want to make first 10 minutes pistol , 10 minutes rifles and 10 minutes awp

XHUNTERX 05-15-2020 11:03

Re: deathmatch (5 minutes =ak, 10 minutes = awp, 15 minutes = usp)
 
it's better to add an editable version

Ejziponken 05-15-2020 11:22

Re: deathmatch (5 minutes =ak, 10 minutes = awp, 15 minutes = usp)
 
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;
}


XHUNTERX 05-15-2020 11:40

Re: deathmatch (5 minutes =ak, 10 minutes = awp, 15 minutes = usp)
 
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));
}



All times are GMT -4. The time now is 03:08.

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