Raised This Month: $ Target: $400
 0% 

Why does this plugin makes the server crash?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 01-02-2022 , 16:14   Re: Why does this plugin makes the server crash?
Reply With Quote #1

Skip the other game modes too + what natsheh said above.

Code:
public zp_round_started(gamemode, id) {     for (new id = 1; id <= g_maxplayers; id++)         g_has_item[id] = false;     if (gamemode != MODE_PLAGUE && gamemode != MODE_SURVIVOR && gamemode != MODE_SNIPER ) // etc...         set_task(2.0, "give_item_task", TASK_STARTGIVE); }

Code:
#include <amxmodx> #include <zombie_plague_advance> /*================================================================================  [Plugin Customization] =================================================================================*/ // Items name (note: add exact item name) new const EXTRA_ITEMS[][] = {     "Plasma Gun",     "Golden Ak 47",     "Item3" } /*================================================================================  Customization ends here! Yes, that's it. Editing anything beyond  here is not officially supported. Proceed at your own risk... =================================================================================*/ enum {     TASK_STARTGIVE = 298,     TASK_GIVEITEM } #define ID_BOT (taskid - TASK_GIVEITEM) new cvar_max_bots, g_botname[33][32], g_has_item[33], g_maxplayers; public plugin_init() {     /* Plugin register */     register_plugin("[ZP] Bot Addon: Force buy items", "v0.2", "Crazy");     /* Cvars */     cvar_max_bots = register_cvar("zp_force_buy_maxbots", "5");     /* Max players */     g_maxplayers = get_maxplayers() } public client_putinserver(id) {     if (is_user_bot(id))         get_user_name(id, g_botname[id], charsmax(g_botname[])); } public zp_round_started(gamemode, id) {     for (new id = 1; id <= g_maxplayers; id++)         g_has_item[id] = false;     if (gamemode != MODE_PLAGUE && gamemode != MODE_SURVIVOR && gamemode != MODE_SNIPER)         set_task(2.0, "give_item_task", TASK_STARTGIVE); } public give_item_task(taskid) {     static id, iBots, iMaxBots;     iBots = 0;     iMaxBots = get_pcvar_num(cvar_max_bots);     /* Why do you loop here? You can create an infinite loop because not everytime botid will be different. */     for (new i; i <= iMaxBots; i++)     {         id = get_random_bot(i);         // We dont have any more bots, break the loop         if(id == -2)             break;         if (!is_user_alive(id))             continue;         if (zp_get_user_zombie(id))             continue;         if (g_has_item[id])             continue;         set_task(1.0, "give_item", id+TASK_GIVEITEM);         iBots++;     }     remove_task(TASK_STARTGIVE);     remove_task(TASK_GIVEITEM); } public give_item(taskid) {     static id, random, itemid;     id = ID_BOT;     random = random_num(0, sizeof EXTRA_ITEMS - 1);     itemid = zp_get_extra_item_id(EXTRA_ITEMS[random]);     if (itemid == -1)     {         set_task(0.5, "give_item", id+TASK_GIVEITEM);         return;     }     zp_force_buy_extra_item(id, itemid, 1);     g_has_item[id] = true;     remove_task(id+TASK_GIVEITEM); } get_random_bot(index) {     new iPlayers[MAX_PLAYERS], iNum;     get_players(iPlayers, iNum, "ad");     if(iNum < index)         return -2;     return iNum > 0 ? iPlayers[index] : -1; }

Not tested.
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]

Last edited by Shadows Adi; 01-02-2022 at 16:32. Reason: lmfao, forgot to text
Shadows Adi is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-02-2022 , 16:16   Re: Why does this plugin makes the server crash?
Reply With Quote #2

Quote:
Originally Posted by Shadows Adi View Post
Skip the game modes if

Code:
public zp_round_started(gamemode, id) {     for (new id = 1; id <= g_maxplayers; id++)         g_has_item[id] = false;     if (gamemode != MODE_PLAGUE && gamemode != MODE_SURVIVOR && gamemode != MODE_SNIPER ) // etc...         set_task(2.0, "give_item_task", TASK_STARTGIVE); }

What?
__________________
@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
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 01-02-2022 , 16:33   Re: Why does this plugin makes the server crash?
Reply With Quote #3

Quote:
Originally Posted by Natsheh View Post
What?
My bad, forgot to text the message lmao
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi 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 11:30.


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