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

[L4D2] I will keep this weapon (0.8, 2010-11-15)


Post New Thread Reply   
 
Thread Tools Display Modes
Author
hpcorona
Junior Member
Join Date: Nov 2010
Plugin ID:
2075
Plugin Version:
0.8
Plugin Category:
Gameplay
Plugin Game:
Left 4 Dead
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    L4D2 plugin to keep your weapons on map changes on a Versus game.
    Unapprover:
    Reason for Unapproving:
    Feedback given: https://forums.alliedmods.net/showpost.php?p=1598805&postcount=11 Author not active since posting.
    Old 11-14-2010 , 14:29   [L4D2] I will keep this weapon (0.8, 2010-11-15)
    Reply With Quote #1

    About:
    This is the first plugin of Muy Matón (me). Don't be rude, these are my first steps on the modding universe.
    Description:
    A plugin to make versus games more interesting...

    You've just got your magnum at the end of the chapter... bad luck, you're gonna loose it starting the next chapter. NOT ANYMORE!

    The point system gave the other team the same points as your team but the other team where all almost death? Not a problem! now they will start with the health they finished the last chapter. Nice.
    cvars:
    • keep_primary convar to keep the primary weapon between maps. Defaults to 1.
    • keep_secondary convar to keep the secondary (pistol/melee) weapon between maps. Defaults to 1. If you have a melee weapon, it will load fireaxe always on map change. I still have to make this work right.
    • keep_throwable convar to keep the throwable (pipebomb, etc...) between maps. Defaults to 1.
    • keep_medkit convar to keep the medkit/defilibrator between maps. Defaults to 1.
    • keep_pills convar to keep the pills/adrenaline between maps. Defaults to 1.
    • keep_health convar to keep the the health between maps. No more 100% health on a new map. Defaults to 1.
    • keep_min_health convar to set the minimum health to restore. The plugin will restore at least this amount of health. Defaults to 25.
    • keep_commands_enabled convar to allow the use of keep_save and keep_load console commands. keep_save will save all slots, and keep_load will restore them. Can only be restored once. Defaults to 0.

    Changelog:
    • 2010-11-14 version 0.7. Initial version.
    • 2010-11-15 verison 0.8. Pills not saving/restoring, new melee weapon giving implementation (save using the model name, and restores checking for a pre-cached model), now only works with versus/teamversus, new convar 'keep_min_health', added autoexecconfig, changed comments to english, added a new field so it is now possible to free up space on the static array, and now the weapons keeps lasersights, upgrades (inciendiary/explosive rounds), current ammo and clip ammo.

    Plans:
    • Make the plugin work propertly (has some issues, is still not very stable).
    • Implement a way to avoid cheating (player disconnecting and reconnecting latter to get a good loadout).
    Attached Files
    File Type: sp Get Plugin or Get Source (keepthisweapon-l4d2.sp - 1131 views - 19.7 KB)

    Last edited by Dr!fter; 11-18-2011 at 19:35. Reason: update
    hpcorona is offline
    Jоnny
    Senior Member
    Join Date: Jun 2007
    Old 11-15-2010 , 08:00   Re: [L4D2] I will keep this weapon (0.9, 2010-11-14)
    Reply With Quote #2

    something wrong with "pills" slot?



    SavePills(client, idx);
    RestorePills(client, idx);

    Code:
    public SaveSecondary(client, idx)
    {
        decl String:modelname[128];
        GetEntPropString(GetPlayerWeaponSlot(client, 1), Prop_Data, "m_ModelName", modelname, 128);
        if (StrEqual(modelname, "models/weapons/melee/v_fireaxe.mdl", false))
        {
            slotSecondary[idx] = "fireaxe";
            return;
        }
        if (StrEqual(modelname, "models/weapons/melee/v_crowbar.mdl", false))
        {
            slotSecondary[idx] = "crowbar";
            return;
        }
        if (StrEqual(modelname, "models/weapons/melee/v_cricket_bat.mdl", false))
        {
            slotSecondary[idx] = "cricket_bat"; // problem with "weapon_". removing "weapon_" is wrong. "give weapon_pistol" works fine.
            return;
        } 
        if (StrEqual(modelname, "models/weapons/melee/v_katana.mdl", false))
        {
            slotSecondary[idx] = "katana";
            return;
        }
        if (StrEqual(modelname, "models/weapons/melee/v_bat.mdl", false))
        {
            slotSecondary[idx] = "baseball_bat";
            return;
        }
        if (StrEqual(modelname, "models/v_models/v_knife_t.mdl", false))
        {
            slotSecondary[idx] = "knife";
            return;
        }
        if (StrEqual(modelname, "models/weapons/melee/v_electric_guitar.mdl", false))
        {
            slotSecondary[idx] = "electric_guitar";
            return;
        }
        if (StrEqual(modelname, "models/weapons/melee/v_frying_pan.mdl", false))
        {
            slotSecondary[idx] = "frying_pan";
            return;
        }
        if (StrEqual(modelname, "models/weapons/melee/v_machete.mdl", false))
        {
            slotSecondary[idx] = "machete";
            return;
        }
        if (StrEqual(modelname, "models/weapons/melee/v_golfclub.mdl", false))
        {
            slotSecondary[idx] = "golfclub";
            return;
        }
        if (StrEqual(modelname, "models/weapons/melee/v_tonfa.mdl", false))
        {
            slotSecondary[idx] = "tonfa";
            return;
        }
        if (StrEqual(modelname, "models/weapons/melee/v_riotshield.mdl", false))
        {
            slotSecondary[idx] = "riotshield";
            return;
        }
    //    PrintToChatAll("\x03ModelName = %s", modelname);
        GetEdictClassname(GetPlayerWeaponSlot(client, 1), slotSecondary[idx], MAX_LINE_WIDTH);
        return;
    }

    Last edited by Jоnny; 11-15-2010 at 09:10.
    Jоnny is offline
    AtomicStryker
    Veteran Member
    Join Date: Apr 2009
    Location: Teutonia!!
    Old 11-15-2010 , 11:33   Re: [L4D2] I will keep this weapon (0.9, 2010-11-14)
    Reply With Quote #3

    Nice Idea. Keeping health between maps is a fresh approach to versus, although you could abuse this by disconnecting with a good loadout, then reconnecting on next map and getting it all back.


    Suggestions:

    Keep code comments in english, so other people can follow your thoughts

    PHP Code:
    public SaveClientData(client)

    public 
    FindSteamID(String:SteamID[]) 
    There is no need to make all your 'private' functions public. You could also make the String in that function const, since it doesnt change anymore.


    PHP Code:
    public LogPluginAction(String:action[], String:name[], client) {
        
    decl String:clientName[200];
        
    GetClientName(clientclientNamesizeof(clientName));
        
        
    LogToGame("%s '%s' for %s"actionnameclientName);

    No need for this function, simply use

    PHP Code:
    LogToGame("%s '%s' for %N"actionnameclient); 


    You re-give melee weapons? Aren't there model precache issues on some maps?


    Consider using a Trie or something to save data instead of a static 64 player global, on a 10on10 server you'll have this filled in no time and then what? Or at least wipe this global if a certain player left the server and doesnt come back for a certain time.


    I see you only restore m_iHealth. That would bring someone who was on Pills only back with 1 health. Consider just transforming temporary health into hard health, as the Survivors could rest and all.
    AtomicStryker is offline
    hpcorona
    Junior Member
    Join Date: Nov 2010
    Old 11-15-2010 , 14:14   Re: [L4D2] I will keep this weapon (0.9, 2010-11-14)
    Reply With Quote #4

    Lots of thanks for the comments!

    As i said before, this is my first plugin...

    I'll be making tests and implement your suggestions this week.

    There are some problems on some map changes, it works weird sometimes. Lot's of tests to do.

    Thanks agean.
    hpcorona is offline
    hpcorona
    Junior Member
    Join Date: Nov 2010
    Old 11-15-2010 , 14:21   Re: [L4D2] I will keep this weapon (0.9, 2010-11-14)
    Reply With Quote #5

    Quote:
    Originally Posted by Jоnny View Post
    something wrong with "pills" slot?
    Thanks a lot for the code snippet and code debugging...

    When testing i saw that there were issues with model pre-caching... as mentioned before... Does someone knows how to find out wich melee weapon is "safe" to use on each map? At least for the official maps...

    Agean, thanx a lot for the code spinnets.
    hpcorona is offline
    Jоnny
    Senior Member
    Join Date: Jun 2007
    Old 11-15-2010 , 14:55   Re: [L4D2] I will keep this weapon (0.9, 2010-11-14)
    Reply With Quote #6

    Quote:
    Originally Posted by hpcorona View Post
    Does someone knows how to find out wich melee weapon is "safe" to use on each map?
    IsModelPrecached()
    true/false
    Jоnny is offline
    Mr. Zero
    Veteran Member
    Join Date: Jun 2009
    Location: Denmark
    Old 11-15-2010 , 15:40   Re: [L4D2] I will keep this weapon (0.9, 2010-11-14)
    Reply With Quote #7

    Another small suggestion:

    Add FCVAR_DONTRECORD to your version cvar, so it doesnt show up in the auto config and remove replicated and sponly as you dont need these.

    And then create the auto config, with AutoExecConfig
    Mr. Zero is offline
    hpcorona
    Junior Member
    Join Date: Nov 2010
    Old 11-15-2010 , 21:22   Re: [L4D2] I will keep this weapon (0.9, 2010-11-14)
    Reply With Quote #8

    Updated with most of your suggestions... I just had problems with one suggestion...

    Quote:
    Originally Posted by AtomicStryker View Post
    Consider using a Trie or something to save data instead of a static 64 player global, on a 10on10 server you'll have this filled in no time and then what? Or at least wipe this global if a certain player left the server and doesnt come back for a certain time.
    My root languge is spanish, and google didn't helped me understand what a 'trie' is... I'm now detecting wich player is no longer playing to free up a space as needed... Don't know if this is enought or i need to consider something else...

    Agean, thanks for your suggestions, i'm really learning a lot...

    It is not fully tested, and as stated before, it works weird sometimes...

    I just can't get the correct events, if somebody can help, here's what i want to be able to detect:
    • When a player is spawned in the start area of each map... Tryed player_first_spawn and player_entered_start_area but they were not giving me the right results... Checking the logs i saw a text that says Muy Maton spawned as a Producer... I just want to intercept that event after OnEndChangeLevel.
    • Sometimes, data is not restored for team A or team B, i think it's because i am saving the data on client disconnection and maybe they are "spawned" as survivor before map change... I think this because i saw this log message "Muy Maton<2><STEAM_1:1:11455728><Infected>" joined team "Survivor" just before Preparing player entities for changelevel

    Any help on wich events to Hook to is appreciated, trial/error are very time consuming...

    Thanx
    hpcorona is offline
    dirka_dirka
    Veteran Member
    Join Date: Nov 2009
    Old 11-15-2010 , 23:49   Re: [L4D2] I will keep this weapon (0.8, 2010-11-15)
    Reply With Quote #9

    melee weapons are valid for an entire campaign - unless it was spawned by a plugin.. in which case, that plugin should be precaching the model.

    as far as when a map starts:
    round_start fires usually 2 times, then the survivor bots spawn (player_first_spawn), then the player_takeover_bot (or however it is spelled) is fired as each survivor loads in.

    pretty sure player_entered_start_area doesn't fire when they are spawned inside the start area, only after they leave and re-enter.
    dirka_dirka is offline
    AtomicStryker
    Veteran Member
    Join Date: Apr 2009
    Location: Teutonia!!
    Old 11-16-2010 , 05:15   Re: [L4D2] I will keep this weapon (0.8, 2010-11-15)
    Reply With Quote #10

    Trie:
    http://docs.sourcemod.net/api/index....ad=file&id=46&
    AtomicStryker 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 00:46.


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