PDA

View Full Version : [Release] [WIP][TF2] Cash For Kills (Progress-Tracking Thread!)


404UserNotFound
03-05-2013, 13:52
So I'm working on this again! See the latest post for more info!

Arrow768
03-05-2013, 14:07
The Basic Store-System should be as basic as possible to be able to use store with as many mods (cs:s,tf2,...) as possible.

For your specific needs a TF2 Store Module would be the correct way. You should post a summary of your request in this thread (https://forums.alliedmods.net/showthread.php?t=208826) if you cant make it yourself.

Why do you need SQL Functions, wouldnt it be easier to use the store native to give credits to a client ?


/**
* Gives multiple players a specific amount of credits.
*
* You can also set the credits parameter to a negative value to take credits
* from the players.
*
* As with all other store-backend methods, this method is completely asynchronous.
*
* @param accountIds The account IDs of the players, use Store_GetClientAccountID to convert a client index to account ID.
* @param accountIdsLength Players count.
* @param credits The amount of credits to give to the players.
*
* @noreturn
*/
native Store_GiveCreditsToUsers(accountIds[], accountIdsLength, credits);


EDIT: Just saw you posted in the request module thread.
I have found the native there (https://github.com/alongubkin/store/blob/master/scripting/include/store/store-backend.inc)

Arrow768
03-05-2013, 14:25
You can get the account id with

Store_GetClientAccountID(client)


If you have a working store plugin, it should handle all the connections to the db when using natives (if you have included the correct store includes)

alongub
03-05-2013, 18:41
Take a look at store-distributor.sp to see an example of how to give credits to a player using the Store_GiveCredits native.

alongub
03-10-2013, 10:31
Should be as simple as

public Action:Event_PlayerStealSandvich(Handle:event , const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "target"));

if (!IsClientInGame(client))
return Plugin_Continue;

if (IsFakeClient(cilent))
return Plugin_Continue;

new credits = GetConVarInt(Credits_StealSandvich);

PrintToChat(client, "\x05[STORE]\x01 You got $%i for stealing a Sandvich", credits);
Store_GiveCredits(Store_GetClientAccountID(cl ient), credits);
}

404UserNotFound
03-12-2013, 15:40
I've repurposed this thread into a progress-tracking thread, now that I've got a pretty good idea of what I'm doing!

vodka00
03-12-2013, 20:16
Woow this is nice man :D

404UserNotFound
03-12-2013, 20:18
Woow this is nice man :D

:oops: Awwww shucks. Thanks!

alongub
03-12-2013, 21:50
Awesome.

Arrow768
03-13-2013, 02:39
Looks very interesting.
Btw. you forgot the ending slash at the

[U]Weapon-Specific Kills[U]


What do you think about storing the settings in the database, so they could be changed via a Webinterface (maybe the WebPanel) ?

eXemplar
03-13-2013, 03:04
What do you think about storing the settings in the database
Could this not be a change that is implemented for the whole store?

404UserNotFound
03-13-2013, 04:33
Looks very interesting.
Btw. you forgot the ending slash at the


What do you think about storing the settings in the database, so they could be changed via a Webinterface (maybe the WebPanel) ?

Only if its made possible by some sort of native because I can't code SQL at all.

Drixevel
03-13-2013, 06:39
Whelp, this scraps the plugin I was making. haha

Arrow768
03-13-2013, 11:27
Maybe we should make a Work In Progress Thread, so developers can see what is being worked on atm and there are no duplicate plugins ?!

404UserNotFound
03-13-2013, 17:04
Maybe we should make a Work In Progress Thread, so developers can see what is being worked on atm and there are no duplicate plugins ?!

Good idea!

Drixevel
03-13-2013, 22:52
Maybe we should make a Work In Progress Thread, so developers can see what is being worked on atm and there are no duplicate plugins ?!

I second this since I wasted a good week or two of my time. haha

Cheers,
- Jack

404UserNotFound
03-14-2013, 12:29
I second this since I wasted a good week or two of my time. haha

Cheers,
- Jack
Haha, oh wow. A week or two? Welp, I just woke up and was going to work on the plugin some more and finish up some events, but I got called into work. Guess I'll have to work on it later.


Whats with all this silly "end your post like it's a letter to your friend" shit,
- abrandnewday

Drixevel
03-14-2013, 12:48
Haha, oh wow. A week or two? Welp, I just woke up and was going to work on the plugin some more and finish up some events, but I got called into work. Guess I'll have to work on it later.


Whats with all this silly "end your post like it's a letter to your friend" shit,
- abrandnewday

I don't dedicate my time to working on plugins. I also use that format a lot when I feel like it.

- Jack

Arrow768
03-14-2013, 16:35
I have created and sticked the WIP-Thread.

404UserNotFound
03-14-2013, 23:28
Update Time!

So I've been pretty busy the past two days, what with having to go to work and all, and I've only had a brief bit of time to work on the plugin tonight, but I've already gotten something worked out for the plugin, which I am now going back through the code to change every instance over to.

It's the addition of two new ConVars which I really should have coded in in the first place. The first ConVar determines if messages are to be displayed upon doing something that earns you cash.

The second ConVar only occurs for certain events (at this time, events such as Ubercharging a teammate, or killing a player) that have the ability to display your victim's name. Setting this second ConVar to "1" will enable the messages to display the victim's name, i.e. "You have earned <amount> <currency name> for killing <victim name>". Setting it to "0" displays a more generic message, for example "You have earned <amount> <currency name> for killing an enemy."

Here's an example:

new displaymsg = GetConVarInt(Credits_DisplayMessages);
if (displaymsg == 1)
{
if (bigstun)
{
new displayname = GetConVarInt(Credits_DisplayNames);
if (displayname == 1)
{
PrintToChat(attacker, "%s%t", STORE_PREFIX, "Moonshotted Player Named", credits_bigstun, g_strCurrencyName, victimname);
}
else
{
PrintToChat(attacker, "%s%t", STORE_PREFIX, "Moonshotted Player", credits_bigstun, g_strCurrencyName);
}
}
else
{
new displayname = GetConVarInt(Credits_DisplayNames);
if (displayname == 1)
{
PrintToChat(attacker, "%s%t", STORE_PREFIX, "Stunned Player", credits_stun, g_strCurrencyName, victimname);
}
else
{
PrintToChat(attacker, "%s%t", STORE_PREFIX, "Stunned Player", credits_stun, g_strCurrencyName);
}
}
}

The code is all expanded because that's how I roll. I will of course try my damndest to minimize the # of lines in the code using some popular methods of shrinking the amount of lines of code, such as:

if (displayname == 1) { PrintToChat(attacker, "%s%t", STORE_PREFIX, "Moonshotted Player Named", credits_bigstun, g_strCurrencyName, victimname); }

As well, I've also added a new event or two, in regards to the CTF game mode. Instead of just being able to get cash for capturing the Intel (along with the team bonus for capturing the intel), you will also have the option to set up an amount of credits to reward players who grab the Intel, or who defend the Intel.

I've just added Grabbing the Intel and Defending the Intel to the main post :D

404UserNotFound
03-15-2013, 17:53
Another Update

So after doing some reading on the AlliedMods wiki, I think I'm competent enough to figure out how to make this plugin load stuff from a config file instead of convars. With that being said, I'm going to finish work on the current version so I have everything finished and coded up, then I'll get to work on converting it to use a config file.

Hopefully I don't end up screwing everything up horribly D:

EDIT: Actually, I think I'll set everything up via CVAR and release that as a CVAR version, then I'll try my hand at modifying it to make it a config file loader, then I'll release the config file version. 2 separate versions!

lol nope, nevermind. way too much work to set up a config file. screw that.

404UserNotFound
04-06-2013, 20:16
Main post has been updated, source code of what I worked on has been released. It's nowhere near finished, and I sadly don't have a lot of time to work on it any more. Check the main post's attachment for the source code.

404UserNotFound
05-10-2013, 12:48
Ooh, a new update!

So I recently started working on this plugin again, starting where I left off originally.

As I've probably stated before, I'm saving the "player_death" event for last, because that event will contain the coding for giving credits for each specific type of kill with every weapon which is going to be a pain in my ass.

I know I already released the source code of what I've completed thus far, so if you are one of the people who grabbed the source code, feel free to keep working on it as well.

And hey, I don't even know if I've coded this thing up correctly thus far, and if it will even give credits properly. So yeah. I'm gonna be poking around the coding a bit to see if I can make some significant progress in finishing this huge project.

I've not yet seen anyone else release a TF2 credits for kills plugin yet (other than that already existing, very basic version that whats-his-name released).

With that being said, away I go!

404UserNotFound
11-28-2013, 12:22
Ok, so another update. I completely forgot about this plugin, what with my being busy working on my Boss Spawner Deluxe plugin.

Whilst perusing my coding folder, I happened upon this plugin and thought to myself "Was I supposed to be working on this, or did I just give up on it?".

Then I checked this thread and apparently I was supposed to be working on it. So I'm working on it again. Basically all I have left to do is the death event, setting up cash amount convars for each and every weapon in TF2, as well as any other death-related stuff (such as losing points when you die)

I won't be setting up any fancy stuff to detect the new Australium or Killstreak weapons because they're just normal weapons with fancy add-ons. The only issue is, I need to figure out the weapon names for some of the newer things like the Australium Frying Pan (because that is considered its own weapon). For example, the Nessie's Nine Iron is labelled internally as "nessieclub".

Scream Fortress 2013 spells are going to be added, as I already have a few "classnames" for some of the deadly spells, as some servers may use the Set Spell plugin, so I want to make sure the spells are added in. Here's the names I've gotten thus far:

spellbook_fireball
spellbook_boss
spellbook_lightning
spellbook_skeleton
spellbook_athletic
spellbook_meteorAs well, I know Valve recently messed with something to do with Jarate and Mad Milk, but I'm not sure if their messing-around modified the current weapon name for both weapons which is just "jar".

If anyone knows where I can find a list of all the weapon names ingame, or a way to generate a list of them, please let me know!

EDIT: Found out where to find this info. It's all in items_game.txt. Golden Frying Pan is "golden_fryingpan", by the way.