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

Why does this plugin makes the server crash?


Post New Thread Reply   
 
Thread Tools Display Modes
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-04-2022 , 05:11   Re: Why does this plugin makes the server crash?
Reply With Quote #11

This is an invalid check

if (gamemode != MODE_PLAGUE || MODE_SURVIVOR)

Should be


if (gamemode != MODE_PLAGUE && gamemode != MODE_SURVIVOR)
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 01-04-2022 , 06:46   Re: Why does this plugin makes the server crash?
Reply With Quote #12

Quote:
By the way, are you aware that the same bot can't buy extra items more than once during one round?
Bots will buy an item only once at the beginning of the round, that is how I made it. If you want it so that bots buy an item every time they become a human, use this plugin instead.

Code:
#include <amxmodx>
#include <zombieplague>

new const EXTRA_ITEMS[][] = {
	"Balrog Ethereal"
}

new g_extraItems[sizeof EXTRA_ITEMS], g_extraItemCount

public plugin_init()
{
	register_plugin("Bots Buy Extra Items", "1.1", "Ainsley Harriott")
}

public plugin_cfg()
{
	for (new i, itemid; i < sizeof EXTRA_ITEMS; i++)
	{
		itemid = zp_get_extra_item_id(EXTRA_ITEMS[i])

		if (itemid != -1)
		{
			g_extraItems[g_extraItemCount++] = itemid
		}
	}
}

public zp_user_humanized_post(id, survivor)
{
	if (g_extraItemCount > 0 && is_user_bot(id))
	{
		new itemid = g_extraItems[random(g_extraItemCount)]
		zp_force_buy_extra_item(id, itemid, 1)
	}
}
Quote:
Also, will the new plugin give extra items to humans and zombies, or only to humans?
Currently, only humans will buy extra items, if you need it to also work with zombies, use this

Code:
#include <amxmodx>
#include <zombieplague>

new const HUMAN_ITEMS[][] = {
	"Balrog Ethereal"
}

new const ZOMBIE_ITEMS[][] = {
	"Madness"
}

new g_humanExtraItems[sizeof HUMAN_ITEMS], g_humanExtraItemCount
new g_zombieExtraItems[sizeof ZOMBIE_ITEMS], g_zombieExtraItemCount

public plugin_init()
{
	register_plugin("Bots Buy Extra Items", "1.1", "Ainsley Harriott")
}

public plugin_cfg()
{
	for (new i, itemid; i < sizeof HUMAN_ITEMS; i++)
	{
		itemid = zp_get_extra_item_id(HUMAN_ITEMS[i])

		if (itemid != -1)
		{
			g_humanExtraItems[g_humanExtraItemCount++] = itemid
		}
	}

	for (new i, itemid; i < sizeof ZOMBIE_ITEMS; i++)
	{
		itemid = zp_get_extra_item_id(ZOMBIE_ITEMS[i])

		if (itemid != -1)
		{
			g_zombieExtraItems[g_zombieExtraItemCount++] = itemid
		}
	}
}

public zp_user_humanized_post(id, survivor)
{
	if (g_humanExtraItemCount > 0 && is_user_bot(id))
	{
		new itemid = g_humanExtraItems[random(g_humanExtraItemCount)]
		zp_force_buy_extra_item(id, itemid, 1)
	}
}

public zp_user_infected_post(id, infector, nemesis)
{
	if (g_zombieExtraItemCount > 0 && is_user_bot(id))
	{
		new itemid = g_zombieExtraItems[random(g_zombieExtraItemCount)]
		zp_force_buy_extra_item(id, itemid, 1)
	}
}
Quote:
Will the plugin give extra items during any game mode, or only during normal infection mode? Does that mean that the second plugin will give extra items during any game mode, just because there are no checks to detect the game modes listed as modes during which extra items shouldn't be given to bots
Yes exactly, there are no checks for which mode is currently being played, the bots should be able to buy items anytime as long as the item is available.


Code:
// Wrong
if (gamemode != MODE_PLAGUE || MODE_SURVIVOR)

// Right
if (gamemode != MODE_PLAGUE && gamemode != MODE_SURVIVOR)
This part simply means "if the current mode is any but plague and survivor, call the function that will give items to the bots".

I'm not sure if those are the answers you're looking for. If you still have doubts feel free to ask
__________________








CrazY. is offline
GlobalPlague
Senior Member
Join Date: Feb 2016
Location: Pluto
Old 01-26-2022 , 11:49   Re: Why does this plugin makes the server crash?
Reply With Quote #13

Quote:
Originally Posted by Natsheh View Post
Here a better + fixed function to get a random bot with no replication!!

I saw alot of coders struggle to create such function there you go, try understanding...

PHP Code:
get_random_bot(arrNoReplicate[MAX_PLAYERS]="", &ReplicateSize=0)
{
    static 
iPlayers[MAX_PLAYERS], iNum;

    
get_players(iPlayersiNum"adh");

    if( 
ReplicateSize )
    {
        for(new 
ijiNumj++)
       {
           for(
0ReplicateSizei++)
           {
                if(
iPlayers] == arrNoReplicate])
                     
iPlayersj-- ] = iPlayers [ --iNum ];
           }
       }
    }
    
    if(!
iNum// uncomment and remove return 0; in the following if you want the function to never fails until legitimately there are no alive bots exists.
    
{
        
//ReplicateSize = 0;
        //get_players(iPlayers, iNum, "adh");
        
return 0;
    }

    new 
iChosen 0;

    if( 
iNum )
    {
        
iChosen iPlayersrandom(iNum) ] ;
        if(
MAX_PLAYERS ReplicateSizearrNoReplicate ReplicateSize++ ] = iChosen;
    }
        
    return 
iChosen;


This how to use inside the following function...

PHP Code:
public give_item_task(taskid)
{
    static 
iMaxBots;
    
iMaxBots get_pcvar_num(cvar_max_bots);

    for (new 
iidoldbots[MAX_PLAYERS], oldbots_countiMaxBotsi++)
    {
        if(! (
id get_random_bot(oldbotsoldbots_count)) )
            break;

        if (
zp_get_user_zombie(id))
            continue;

        if (
g_has_item[id])
            continue;

        
set_task(1.0"give_item"id+TASK_GIVEITEM);
    }

Is this code going to fix the crash, caused by the plugin i posted in my original post? If yes, would you explain me where to put the code you gave me?
GlobalPlague is offline
GlobalPlague
Senior Member
Join Date: Feb 2016
Location: Pluto
Old 01-26-2022 , 11:56   Re: Why does this plugin makes the server crash?
Reply With Quote #14

Quote:
Originally Posted by CrazY. View Post
Don't use that plugin, it's complete garbage and I know, I'm the author. Use this one, will work on any game mode.

Code:
#include <amxmodx>
#include <zombieplague>

new const EXTRA_ITEMS[][] = {
	"Balrog Ethereal"
}

new cvar_max_bots

new g_extraItems[sizeof EXTRA_ITEMS], g_extraItemCount

public plugin_init()
{
	register_plugin("Bots Buy Extra Items", "1.1", "Ainsley Harriott")
	cvar_max_bots = register_cvar("zp_force_buy_maxbots", "3")
}

public plugin_cfg()
{
	for (new i, itemid; i < sizeof EXTRA_ITEMS; i++)
	{
		itemid = zp_get_extra_item_id(EXTRA_ITEMS[i])

		if (itemid != -1)
		{
			g_extraItems[g_extraItemCount++] = itemid
		}
	}
}

public zp_round_started(gamemode, id)
{
	if (g_extraItemCount > 0)
	{
		GiveBotExtraItems()
	}
}

GiveBotExtraItems()
{
	new bots[32], botCount
	new humanBots[32], humanBotCount

	get_players(bots, botCount, "adh")

	for (new i, bot; i < botCount; i++)
	{
		bot = bots[i]

		if (!zp_get_user_zombie(bot))
		{
			humanBots[humanBotCount++] = bot
		}
	}

	SortIntegers(humanBots, humanBotCount, Sort_Random)

	for (new i, bot, itemid, max = min(humanBotCount, get_pcvar_num(cvar_max_bots)); i < max; i++)
	{
		bot = humanBots[i]
		itemid = g_extraItems[random(g_extraItemCount)]
		zp_force_buy_extra_item(bot, itemid, 1)
	}
}
Hello. When i tried to compile the code you gave me, i got the following 2 errors:

//AMXXPC compile.exe
// by the AMX Mod X Dev Team


//// buy_extra_items.sma
// C:\Mod\cstrike\addons\amxmodx\scripting\bot_s upport_extra_items.sma(56) : error 017: undefined symbol "Sort_Random"
// C:\Mod\cstrike\addons\amxmodx\scripting\bot_s upport_extra_items.sma(56 -- 5 : error 088: number of arguments does not match definition


Here is the whole code that contains the lines that are the source of errors (the lines are marked in red):

Code:
GiveBotExtraItems()
{
	new bots[32], botCount
	new humanBots[32], humanBotCount

	get_players(bots, botCount, "adh")

	for (new i, bot; i < botCount; i++)
	{
		bot = bots[i]

		if (!zp_get_user_zombie(bot))
		{
			humanBots[humanBotCount++] = bot
		}
	}

	SortIntegers(humanBots, humanBotCount, Sort_Random)

	for (new i, bot, itemid, max = min(humanBotCount, get_pcvar_num(cvar_max_bots)); i < max; i++)
	{
		bot = humanBots[i]
		itemid = g_extraItems[random(g_extraItemCount)]
		zp_force_buy_extra_item(bot, itemid, 1)
	}
}
GlobalPlague is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 01-28-2022 , 15:25   Re: Why does this plugin makes the server crash?
Reply With Quote #15

replace with this
Code:
GiveBotExtraItems()
{
	new bots[32], botCount
	new humanBots[32], humanBotCount

	get_players(bots, botCount, "adh")

	for (new i, bot; i < botCount; i++)
	{
		bot = bots[i]

		if (!zp_get_user_zombie(bot))
		{
			humanBots[humanBotCount++] = bot
		}
	}

	//SortIntegers(humanBots, humanBotCount, Sort_Random)
	SortCustom1D(humanBots, humanBotCount, "RandomlySortBots")

	for (new i, bot, itemid, max = min(humanBotCount, get_pcvar_num(cvar_max_bots)); i < max; i++)
	{
		bot = humanBots[random(humanBotCount)]
		itemid = g_extraItems[random(g_extraItemCount)]
		zp_force_buy_extra_item(bot, itemid, 1)
	}
}

public RandomlySortBots()
{
	return random_num(-1, 1)
}
__________________








CrazY. is offline
Old 01-30-2022, 03:40
GlobalPlague
This message has been deleted by GlobalPlague.
GlobalPlague
Senior Member
Join Date: Feb 2016
Location: Pluto
Old 01-30-2022 , 03:43   Re: Why does this plugin makes the server crash?
Reply With Quote #16

Quote:
Originally Posted by CrazY. View Post
replace with this
Code:
GiveBotExtraItems()
{
	new bots[32], botCount
	new humanBots[32], humanBotCount

	get_players(bots, botCount, "adh")

	for (new i, bot; i < botCount; i++)
	{
		bot = bots[i]

		if (!zp_get_user_zombie(bot))
		{
			humanBots[humanBotCount++] = bot
		}
	}

	//SortIntegers(humanBots, humanBotCount, Sort_Random)
	SortCustom1D(humanBots, humanBotCount, "RandomlySortBots")

	for (new i, bot, itemid, max = min(humanBotCount, get_pcvar_num(cvar_max_bots)); i < max; i++)
	{
		bot = humanBots[random(humanBotCount)]
		itemid = g_extraItems[random(g_extraItemCount)]
		zp_force_buy_extra_item(bot, itemid, 1)
	}
}

public RandomlySortBots()
{
	return random_num(-1, 1)
}
Quote:
Originally Posted by CrazY. View Post
replace with this
Code:
GiveBotExtraItems()
{
	new bots[32], botCount
	new humanBots[32], humanBotCount

	get_players(bots, botCount, "adh")

	for (new i, bot; i < botCount; i++)
	{
		bot = bots[i]

		if (!zp_get_user_zombie(bot))
		{
			humanBots[humanBotCount++] = bot
		}
	}

	//SortIntegers(humanBots, humanBotCount, Sort_Random)
	SortCustom1D(humanBots, humanBotCount, "RandomlySortBots")

	for (new i, bot, itemid, max = min(humanBotCount, get_pcvar_num(cvar_max_bots)); i < max; i++)
	{
		bot = humanBots[random(humanBotCount)]
		itemid = g_extraItems[random(g_extraItemCount)]
		zp_force_buy_extra_item(bot, itemid, 1)
	}
}

public RandomlySortBots()
{
	return random_num(-1, 1)
}
Thank, you CrazY. Now, the plugin works fine, and there are no crashes.

When i added Plasma Gun, the plugin worked. But, the compiler began showing the following error, after i added a second weapon.

Here is the error:

C:\Mod\cstrike\addons\amxmodx\scripting\bot_s upport_extra_items.sma(6) : error 001: expected token: "}", but found "-string-"

Here is the whole code (line 6 is marked in red):

If you can't see where line 6 is, press Ctrl+F, and type the following: "Golden AK-47 \y(\r10x DMG\y)".

Code:
#include <amxmodx>
#include <zombieplague>

new const EXTRA_ITEMS[][] = {
	"Plasma Gun"
	"Golden AK-47 \y(\r10x DMG\y)"
}

new cvar_max_bots

new g_extraItems[sizeof EXTRA_ITEMS], g_extraItemCount

public plugin_init()
{
	register_plugin("Bots Buy Extra Items", "1.1", "Ainsley Harriott")
	cvar_max_bots = register_cvar("zp_force_buy_maxbots", "3")
}

public plugin_cfg()
{
	for (new i, itemid; i < sizeof EXTRA_ITEMS; i++)
	{
		itemid = zp_get_extra_item_id(EXTRA_ITEMS[i])

		if (itemid != -1)
		{
			g_extraItems[g_extraItemCount++] = itemid
		}
	}
}

public zp_round_started(gamemode, id)
{
	if (g_extraItemCount > 0)
	{
		GiveBotExtraItems()
	}
}

GiveBotExtraItems()
{
	new bots[32], botCount
	new humanBots[32], humanBotCount

	get_players(bots, botCount, "adh")

	for (new i, bot; i < botCount; i++)
	{
		bot = bots[i]

		if (!zp_get_user_zombie(bot))
		{
			humanBots[humanBotCount++] = bot
		}
	}

	//SortIntegers(humanBots, humanBotCount, Sort_Random)
	SortCustom1D(humanBots, humanBotCount, "RandomlySortBots")

	for (new i, bot, itemid, max = min(humanBotCount, get_pcvar_num(cvar_max_bots)); i < max; i++)
	{
		bot = humanBots[random(humanBotCount)]
		itemid = g_extraItems[random(g_extraItemCount)]
		zp_force_buy_extra_item(bot, itemid, 1)
	}
}

public RandomlySortBots()
{
	return random_num(-1, 1)
}
So, can someone help me fix this error?

Last edited by GlobalPlague; 01-30-2022 at 03:49.
GlobalPlague is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-30-2022 , 05:06   Re: Why does this plugin makes the server crash?
Reply With Quote #17

Add a comm after "Plasma Gun",

Infact add a comma after each item name but not the last one.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 01-30-2022 at 05:07.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
GlobalPlague
Senior Member
Join Date: Feb 2016
Location: Pluto
Old 01-30-2022 , 20:58   Re: Why does this plugin makes the server crash?
Reply With Quote #18

Quote:
Originally Posted by Natsheh View Post
Add a comm after "Plasma Gun",

Infact add a comma after each item name but not the last one.
Thanks for helping me. Now, the plugin works perfectly after i added the comma.
GlobalPlague is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 02-01-2022 , 09:23   Re: Why does this plugin makes the server crash?
Reply With Quote #19

Made a small mistake, should be like this instead

Code:
GiveBotExtraItems()
{
	new bots[32], botCount
	new humanBots[32], humanBotCount

	get_players(bots, botCount, "adh")

	for (new i, bot; i < botCount; i++)
	{
		bot = bots[i]

		if (!zp_get_user_zombie(bot))
		{
			humanBots[humanBotCount++] = bot
		}
	}

	//SortIntegers(humanBots, humanBotCount, Sort_Random)
	SortCustom1D(humanBots, humanBotCount, "RandomlySortBots")

	for (new i, bot, itemid, max = min(humanBotCount, get_pcvar_num(cvar_max_bots)); i < max; i++)
	{
		bot = humanBots[i]
		itemid = g_extraItems[random(g_extraItemCount)]
		zp_force_buy_extra_item(bot, itemid, 1)
	}
}

public RandomlySortBots()
{
	return random_num(-1, 1)
}
__________________








CrazY. is offline
GlobalPlague
Senior Member
Join Date: Feb 2016
Location: Pluto
Old 02-02-2022 , 02:04   Re: Why does this plugin makes the server crash?
Reply With Quote #20

Quote:
Originally Posted by CrazY. View Post
Made a small mistake, should be like this instead

Code:
GiveBotExtraItems()
{
	new bots[32], botCount
	new humanBots[32], humanBotCount

	get_players(bots, botCount, "adh")

	for (new i, bot; i < botCount; i++)
	{
		bot = bots[i]

		if (!zp_get_user_zombie(bot))
		{
			humanBots[humanBotCount++] = bot
		}
	}

	//SortIntegers(humanBots, humanBotCount, Sort_Random)
	SortCustom1D(humanBots, humanBotCount, "RandomlySortBots")

	for (new i, bot, itemid, max = min(humanBotCount, get_pcvar_num(cvar_max_bots)); i < max; i++)
	{
		bot = humanBots[i]
		itemid = g_extraItems[random(g_extraItemCount)]
		zp_force_buy_extra_item(bot, itemid, 1)
	}
}

public RandomlySortBots()
{
	return random_num(-1, 1)
}
What is the difference between this code and the code i gave me previously (the mistaken code)? I use the previous code, and the plugin works fine. Should i use the new code, instead of the old code? If yes, why?
GlobalPlague is offline
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 10:51.


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