This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

[L4D2] Shop [v4.5 | 20 March 2022]


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Plugin ID:
7620
Plugin Version:
4.5
Plugin Category:
Gameplay
Plugin Game:
Left 4 Dead
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Old 05-01-2021 , 20:32   Re: [L4D2] Shop v2.4 (1 May 2021)
    Reply With Quote #1

    Quote:
    Originally Posted by pan0s View Post
    For the listen server, client index over 18 will have the exception "Client index 19 is invalid", so I define it to 18.
    Of course, for the server who have 20+ players, they can change it back to 20+ because the dedicated server has no this problem.
    That's not how you fix that error. The variable MaxClients is dynamic and can change depending on how many players a server can handle. MAXPLAYERS + 1 handles up to 64 players + world/server index which is what you use for global variables.

    To fix the "Client X is invalid" error you usually include this check:
    PHP Code:
    if (client <= MaxClients
    It will make sure that only clients between index 1 to MaxClients will be affected.

    You also need to loop through clients consistently. Even on listen servers, this is still the ideal loop:
    PHP Code:
    for (int i 1<= MaxClientsi++) 
    In your current code, I see loops like this:
    PHP Code:
    for (int i 0MaxClients 1i++) 
    There are only certain cases where you would need to directly affect index 0 for listen servers, but most of the time, index 1 still works.
    __________________
    Psyk0tik is offline
    pan0s
    Senior Member
    Join Date: Nov 2017
    Old 05-02-2021 , 08:31   Re: [L4D2] Shop v2.4 (1 May 2021)
    Reply With Quote #2

    Quote:
    Originally Posted by Crasher_3637 View Post
    That's not how you fix that error. The variable MaxClients is dynamic and can change depending on how many players a server can handle. MAXPLAYERS + 1 handles up to 64 players + world/server index which is what you use for global variables.

    To fix the "Client X is invalid" error you usually include this check:
    PHP Code:
    if (client <= MaxClients
    It will make sure that only clients between index 1 to MaxClients will be affected.

    You also need to loop through clients consistently. Even on listen servers, this is still the ideal loop:
    PHP Code:
    for (int i 1<= MaxClientsi++) 
    In your current code, I see loops like this:
    PHP Code:
    for (int i 0MaxClients 1i++) 
    There are only certain cases where you would need to directly affect index 0 for listen servers, but most of the time, index 1 still works.
    Thank you for your suggestion, I will apply it to next version.
    pan0s is offline
    Marttt
    Veteran Member
    Join Date: Jan 2019
    Location: Brazil
    Old 05-01-2021 , 12:14   Re: [L4D2] Shop v2.4 (1 May 2021)
    Reply With Quote #3

    Usually, plugins work on listen/local servers unless the author made some "hard-code" to block it. (IsDedicatedServer(), as I already have found in some plugins around the forum).

    What won't work, is being the host and typing plugin commands in the console that uses the client as a parameter to do something, since in listen servers, it will read as being client index = "0" (server). [Anyway there is a workaround for that I do in my plugins]
    The same happens when you try typing plugin commands through console rcon in a dedicated server, for example.

    Also, SM doesn't support listen servers (but I never had any problem with that in 2 years+).
    __________________

    Last edited by Marttt; 05-01-2021 at 12:42.
    Marttt is offline
    mikaelangelis
    Senior Member
    Join Date: Oct 2017
    Old 05-15-2021 , 07:10   Re: [L4D2] Shop [v2.6 | 4 May 2021]
    Reply With Quote #4

    I have an idea. Do you know how to force to create buying area only in safe room?
    mikaelangelis is offline
    VladimirTk
    Senior Member
    Join Date: Apr 2021
    Location: Perú - Latino América
    Old 05-25-2021 , 22:32   Re: [L4D2] Shop [v2.7 | 23 May 2021]
    Reply With Quote #5

    Is it possible to add the command !transfer or !send to send points as a shortcut to open the menu?
    I would make things a little simpler

    Last edited by VladimirTk; 05-25-2021 at 22:32.
    VladimirTk is offline
    Eyedol
    Junior Member
    Join Date: Jul 2018
    Old 05-29-2021 , 18:15   Re: [L4D2] Shop [v2.7 | 23 May 2021]
    Reply With Quote #6

    Code:
    L 05/29/2021 - 15:01:51: [SM] Exception reported: Invalid convar handle 0 (error 4)
    L 05/29/2021 - 15:01:51: [SM] Blaming: l4d2_shop.smx
    L 05/29/2021 - 15:01:51: [SM] Call stack trace:
    L 05/29/2021 - 15:01:51: [SM]   [0] GetConVarInt
    L 05/29/2021 - 15:01:51: [SM]   [1] Line 2564, C:\Users\Eyedol\Desktop\Plugins\sourcemod-1.10.0-git6488-windows\addons\sourcemod\scripting\l4d2_shop.sp::HandleCmdBuyConfirm
    L 05/29/2021 - 15:01:51: [SM]   [3] FakeClientCommand
    L 05/29/2021 - 15:01:51: [SM]   [4] Line 2641, C:\Users\Eyedol\Desktop\Plugins\sourcemod-1.10.0-git6488-windows\addons\sourcemod\scripting\l4d2_shop.sp::HandleCmdRepeatBuy
    L 05/29/2021 - 15:12:21: [SM] Exception reported: Invalid convar handle 0 (error 4)
    L 05/29/2021 - 15:12:21: [SM] Blaming: l4d2_shop.smx
    L 05/29/2021 - 15:12:21: [SM] Call stack trace:
    L 05/29/2021 - 15:12:21: [SM]   [0] GetConVarInt
    L 05/29/2021 - 15:12:21: [SM]   [1] Line 2564, C:\Users\Eyedol\Desktop\Plugins\sourcemod-1.10.0-git6488-windows\addons\sourcemod\scripting\l4d2_shop.sp::HandleCmdBuyConfirm
    L 05/29/2021 - 15:12:21: [SM]   [3] FakeClientCommand
    L 05/29/2021 - 15:12:21: [SM]   [4] Line 2641, C:\Users\Eyedol\Desktop\Plugins\sourcemod-1.10.0-git6488-windows\addons\sourcemod\scripting\l4d2_shop.sp::HandleCmdRepeatBuy
    L 05/29/2021 - 15:27:16: Error log file session closed.
    Hi, I wanted to leave a suggestion and it is that instead of putting an option to restart the points, I think it would be better if they can be restarted by putting the amount you want, as this plugin does for example: https://forums.alliedmods.net/showthread.php?t=278448

    EDIT:

    In addition to putting initial points for each round, I also suggest setting a time to regain initial points when reconnecting, this more than anything to prevent exploits such as someone reconnecting again and again just to give free points to their teammates.

    Last edited by Eyedol; 05-31-2021 at 12:42. Reason: add another suggestion
    Eyedol is offline
    ajaixal11
    Junior Member
    Join Date: Jan 2020
    Old 06-01-2021 , 00:14   Re: [L4D2] Shop [v2.7 | 23 May 2021]
    Reply With Quote #7

    there's a respawn or not? iam req respawn menu
    ajaixal11 is offline
    marki89
    Senior Member
    Join Date: Jun 2020
    Location: Argentina
    Old 06-03-2021 , 10:45   Re: [L4D2] Shop [v2.7 | 23 May 2021]
    Reply With Quote #8

    great job !
    Could you also put it in Spanish? I like so much your work
    marki89 is offline
    pan0s
    Senior Member
    Join Date: Nov 2017
    Old 06-09-2021 , 01:54   Re: [L4D2] Shop [v2.7 | 23 May 2021]
    Reply With Quote #9

    Quote:
    Originally Posted by VladimirTk View Post
    Is it possible to add the command !transfer or !send to send points as a shortcut to open the menu?
    I would make things a little simpler
    Quote:
    Originally Posted by Eyedol View Post
    Code:
    L 05/29/2021 - 15:01:51: [SM] Exception reported: Invalid convar handle 0 (error 4)
    L 05/29/2021 - 15:01:51: [SM] Blaming: l4d2_shop.smx
    L 05/29/2021 - 15:01:51: [SM] Call stack trace:
    L 05/29/2021 - 15:01:51: [SM]   [0] GetConVarInt
    L 05/29/2021 - 15:01:51: [SM]   [1] Line 2564, C:\Users\Eyedol\Desktop\Plugins\sourcemod-1.10.0-git6488-windows\addons\sourcemod\scripting\l4d2_shop.sp::HandleCmdBuyConfirm
    L 05/29/2021 - 15:01:51: [SM]   [3] FakeClientCommand
    L 05/29/2021 - 15:01:51: [SM]   [4] Line 2641, C:\Users\Eyedol\Desktop\Plugins\sourcemod-1.10.0-git6488-windows\addons\sourcemod\scripting\l4d2_shop.sp::HandleCmdRepeatBuy
    L 05/29/2021 - 15:12:21: [SM] Exception reported: Invalid convar handle 0 (error 4)
    L 05/29/2021 - 15:12:21: [SM] Blaming: l4d2_shop.smx
    L 05/29/2021 - 15:12:21: [SM] Call stack trace:
    L 05/29/2021 - 15:12:21: [SM]   [0] GetConVarInt
    L 05/29/2021 - 15:12:21: [SM]   [1] Line 2564, C:\Users\Eyedol\Desktop\Plugins\sourcemod-1.10.0-git6488-windows\addons\sourcemod\scripting\l4d2_shop.sp::HandleCmdBuyConfirm
    L 05/29/2021 - 15:12:21: [SM]   [3] FakeClientCommand
    L 05/29/2021 - 15:12:21: [SM]   [4] Line 2641, C:\Users\Eyedol\Desktop\Plugins\sourcemod-1.10.0-git6488-windows\addons\sourcemod\scripting\l4d2_shop.sp::HandleCmdRepeatBuy
    L 05/29/2021 - 15:27:16: Error log file session closed.
    Hi, I wanted to leave a suggestion and it is that instead of putting an option to restart the points, I think it would be better if they can be restarted by putting the amount you want, as this plugin does for example: https://forums.alliedmods.net/showthread.php?t=278448

    EDIT:

    In addition to putting initial points for each round, I also suggest setting a time to regain initial points when reconnecting, this more than anything to prevent exploits such as someone reconnecting again and again just to give free points to their teammates.
    Quote:
    Originally Posted by ajaixal11 View Post
    there's a respawn or not? iam req respawn menu
    Sorry, I will not update it anymore.

    Quote:
    Originally Posted by marki89 View Post
    great job !
    Could you also put it in Spanish? I like so much your work
    You can translate it by using the en translation.

    Last edited by pan0s; 06-09-2021 at 01:57.
    pan0s is offline
    MarcoG18
    New Member
    Join Date: Oct 2014
    Old 06-28-2021 , 18:57   Re: [L4D2] Shop [v2.7 | 23 May 2021]
    Reply With Quote #10

    I saw your work
    it's excellent
    I just miss one thing
    I would like to leave a suggestion
    Is it possible to put a function that looks like this

    Infected kill = 1 pontos
    Headshot kill = 1 pontos
    Infected kill + headshot = 2

    Special kill = 1 pontos
    Special headshot kill = 1 pontos
    Special kill + headshot kill = 2

    new tankburning[MAXPLAYERS];
    new tankbiled[MAXPLAYERS];
    new witchburning[MAXPLAYERS];

    new killcount[MAXPLAYERS];
    new headshotcount[MAXPLAYERS];



    //Survivor point earning things
    new Handle:SValueKillingSpree = INVALID_HANDLE;
    new Handle:SNumberKill = INVALID_HANDLE;

    new Handle:SValueHeadSpree = INVALID_HANDLE;
    new Handle:SNumberHead = INVALID_HANDLE;
    new Handle:SSIKill = INVALID_HANDLE;

    new Handle:STankKill = INVALID_HANDLE;
    new Handle:SWitchKill = INVALID_HANDLE;
    new Handle:SWitchCrown = INVALID_HANDLE;

    new Handle:STBurn = INVALID_HANDLE;
    new Handle:STSolo = INVALID_HANDLE;
    new Handle:SWBurn = INVALID_HANDLE;






    Notifications = CreateConVar("l4d2_points_notify", "1", "Show messages when points are earned?");


    SValueKillingSpree = CreateConVar("l4d2_points_cikill_value", "2", "How many points does killing a certain amount of infected earn");
    SNumberKill = CreateConVar("l4d2_points_cikills", "20", "How many kills you need to earn a killing spree bounty");

    SValueHeadSpree = CreateConVar("l4d2_points_headshots_value", "4", "How many points does killing a certain amount of infected with headshots earn");
    SNumberHead = CreateConVar("l4d2_points_headshots", "20", "How many kills you need to earn a head hunter bonus");

    SSIKill = CreateConVar("l4d2_points_sikill", "3", "How many points does killing a special infected earn");

    STankKill = CreateConVar("l4d2_points_tankkill", "2", "How many points does killing a tank earn");
    SWitchKill = CreateConVar("l4d2_points_witchkill", "4", "How many points does killing a witch earn");
    SWitchCrown = CreateConVar("l4d2_points_witchcrown", "2", "How many points does crowning a witch earn");

    STSolo = CreateConVar("l4d2_points_tanksolo", "8", "How many points does killing a tank single-handedly earn");
    SWBurn = CreateConVar("l4d2_points_witchburn", "1", "How many points does burning a witch earn");

    STag = CreateConVar("l4d2_points_bile_tank", "2", "How many points does biling a tank earn");

    IKill = CreateConVar("l4d2_points_kill", "5", "How many points does killing a survivor earn");





    public Action:Event_Kill(Handle:event, const String:name[], bool:dontBroadcast)
    {
    new bool:headshot = GetEventBool(event, "headshot");
    ATTACKER
    ACHECK2
    {
    if(headshot) headshotcount[attacker]++;
    new headpoints = GetConVarInt(SValueHeadSpree);
    new heads = GetConVarInt(SNumberHead);

    if(headshotcount[attacker] == heads && headpoints > 0)
    {
    points[attacker] += headpoints;
    headshotcount[attacker] -= heads;
    if(GetConVarBool(Notifications)) PrintToChat(attacker, "%s %T", MSGTAG, "Head Hunter", LANG_SERVER, headpoints);
    }
    killcount[attacker]++;

    new spreepoints = GetConVarInt(SValueKillingSpree);
    new kills = GetConVarInt(SNumberKill);
    if(killcount[attacker] == kills && spreepoints > 0)
    {
    points[attacker] += spreepoints;
    killcount[attacker] -= kills;
    if(GetConVarBool(Notifications)) PrintToChat(attacker, "%s %T", MSGTAG, "Killing Spree", LANG_SERVER, spreepoints);
    }
    }
    }

    public Action:Event_Incap(Handle:event, const String:name[], bool:dontBroadcast)
    {
    ATTACKER
    ACHECK3
    {
    new incappoints = GetConVarInt(IIncap);
    if(incappoints <= 0) return;
    points[attacker] += incappoints;
    if(GetConVarBool(Notifications)) PrintToChat(attacker, "%s %T", MSGTAG, "Incapped Survivor", LANG_SERVER, incappoints);
    }
    }

    public Action:Event_Death(Handle:event, const String:name[], bool:dontBroadcast)
    {
    ATTACKER
    CLIENT
    if(attacker > 0 && client > 0 && !IsFakeClient(attacker) && IsAllowedGameMode() && GetConVarInt(Enable) == 1)
    {
    new bool:notify = GetConVarBool(Notifications);
    if(GetClientTeam(attacker) == 2)
    {
    new sipoints = GetConVarInt(SSIKill);
    if(sipoints < 1 || GetClientTeam(client) == 2 || GetEntProp(client, Prop_Send, "m_zombieClass") == return;
    new bool:headshot = GetEventBool(event, "headshot");
    if(headshot) headshotcount[attacker]++;
    new headsneeded = GetConVarInt(SNumberHead);
    new headpoints = GetConVarInt(SValueHeadSpree);
    if(headshotcount[attacker] == headsneeded && headpoints > 0)
    {
    points[attacker] += headpoints;
    headshotcount[attacker] -= headsneeded;
    if(notify) PrintToChat(attacker, "%s %T", MSGTAG, "Head Hunter", LANG_SERVER, headpoints);
    }
    points[attacker] += sipoints;
    if(notify) PrintToChat(attacker, "%s %T", MSGTAG, "Killed SI", LANG_SERVER, sipoints);
    }
    else if(GetClientTeam(attacker) == 3)
    {
    new killpoints = GetConVarInt(IKill);
    if(killpoints < 1 || GetClientTeam(client) == 3) return;
    points[attacker] += killpoints;
    if(notify) PrintToChat(attacker, "%s %T", MSGTAG, "Killed Survivor", LANG_SERVER, killpoints);
    }
    }
    }

    public Action:Event_TankDeath(Handle:event, const String:name[], bool:dontBroadcast)
    {
    new solo = GetEventBool(event, "solo");
    ATTACKER
    ACHECK2
    {
    new solopoints = GetConVarInt(STSolo);
    if(solo && solopoints > 0)
    {
    points[attacker] += solopoints;
    if(GetConVarBool(Notifications)) PrintToChat(attacker, "%s %T", MSGTAG, "TANK SOLO", LANG_SERVER, solopoints);
    }
    }
    new tankpoints = GetConVarInt(STankKill);
    for (new i=1; i<=MaxClients; i++)
    {
    if(i && IsClientInGame(i)&& !IsFakeClient(i) && IsPlayerAlive(i) && GetClientTeam(i) == 2 && tankpoints > 0 && GetConVarInt(Enable) == 1 && IsAllowedGameMode())
    {
    points[i] += tankpoints;
    if(GetConVarBool(Notifications)) PrintToChat(i, "%s %T", MSGTAG, "Killed Tank", LANG_SERVER, tankpoints);
    }
    }
    tankburning[attacker] = 0;
    tankbiled[attacker] = 0;
    }

    public Action:Event_WitchDeath(Handle:event, const String:name[], bool:dontBroadcast)
    {
    new oneshot = GetEventBool(event, "oneshot");
    CLIENT
    CCHECK2
    {
    new witchpoints = GetConVarInt(SWitchKill);
    if(witchpoints <= 0) return;
    new notify = GetConVarBool(Notifications);
    points[client] += witchpoints;
    new crownpoints = GetConVarInt(SWitchCrown);
    if(oneshot && crownpoints > 0)
    {
    points[client] += crownpoints;
    if(notify) PrintToChat(client, "%s %T", MSGTAG, "Crowned Witch", LANG_SERVER, crownpoints);
    }
    if(notify) PrintToChat(client, "%s %T", MSGTAG, "Killed Witch", LANG_SERVER, witchpoints);
    }
    witchburning[client] = 0;
    }



    public Action:Event_Burn(Handle:event, const String:name[], bool:dontBroadcast)
    {
    new String:victim[30];
    GetEventString(event, "victimname", victim, sizeof(victim));
    CLIENT
    CCHECK2
    {
    new tankpoints = GetConVarInt(STBurn);
    new witchpoints = GetConVarInt(SWBurn);
    if(StrEqual(victim, "Tank", false) && tankburning[client] == 0 && tankpoints > 0)
    {
    points[client] += tankpoints;
    if(GetConVarBool(Notifications)) PrintToChat(client, "%s %T", MSGTAG, "Burn Tank", LANG_SERVER, tankpoints);
    tankburning[client] = 1;
    }
    else if(StrEqual(victim, "Witch", false) && witchburning[client] == 0 && witchpoints > 0)
    {
    points[client] += witchpoints;
    if(GetConVarBool(Notifications)) PrintToChat(client, "%s %T", MSGTAG, "Burn Witch", LANG_SERVER, witchpoints);
    witchburning[client] = 1;
    }
    }
    }
    MarcoG18 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 22:37.


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