Raised This Month: $32 Target: $400
 8% 

Time intervals instead of kills for credits (or certain team kills)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Devoo
Junior Member
Join Date: Mar 2013
Old 06-26-2013 , 01:16   Time intervals instead of kills for credits (or certain team kills)
Reply With Quote #1

How do I make it so credits are given every 5 minutes of game time rather than for every kill. I am using the jail_awards plugin and I will post the script below. Just need to know which part to edit and what to put in (I literally started today and can edit things using a template)
I believe it is using SDKhooks!

If not, if it possible to make it so only if a T kills a CT that a credit is given and if a CT kills a T nothing is given.

I think the code for the credit giving at the moment is:
Code:
public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
    new client = GetClientOfUserId(GetEventInt(event, "userid"));

    CreateTimer(2.0, MensajesMuerte, client);
    
    if (!attacker)
        return;

    if (attacker == client)
        return;
    
    g_iCredits[attacker] += GetConVarInt(cvarCreditsKill);
    
    if (g_iCredits[attacker] < GetConVarInt(cvarCreditsMax))
    {
        PrintToChat(attacker, "\x04[SM_JailAwards] \x05Your credits: %i (+%i)", g_iCredits[attacker],GetConVarInt(cvarCreditsKill));
    }
    else
    {
        g_iCredits[attacker] = GetConVarInt(cvarCreditsMax);
        PrintToChat(attacker, "\x04[SM_JailAwards] \x05Your credits: %i (Maximum allowed)", g_iCredits[attacker]);
    }
}

Thank you!!
Attached Files
File Type: smx jail_awards.smx (13.8 KB, 127 views)
File Type: sp Get Plugin or Get Source (jail_awards.sp - 262 views - 26.6 KB)

Last edited by Devoo; 06-26-2013 at 04:00.
Devoo is offline
Doodil
Senior Member
Join Date: Mar 2012
Old 06-26-2013 , 03:43   Re: Time intervals instead of kills for credits (or certain team kills)
Reply With Quote #2

posting the ".smx" doesn't really help, since this is the compiled version of the code (aka not human readable). If you want to post the code you have to post the ".sp".

To your problem:

Yes that is the part of the code that adds credits. If you want to give the player credits every 5 minutes instead you have to create a timer (timer in the API). For a repeating timer use the flag TIMER_REPEAT (timer flags in the API).

As the optional data value for the CreateTimer function you should pass the userid of the client (Retrieving the userid of a client in the API) and in the callback for the timer you should retrieve the client from the userid (Retrieving the client of a userid in the API) and then check if the player is still in the server. Once you have verified that the client is still on the server you can give him credits in the same way your code-snipped did.


For the team-part:

The GetClientTeam() function (GetClientTeam in the API) allows you to check the team of a player, so if you don't want CTs to get credits for kills you just need to add

Code:
if (GetClientTeam(attacker) == CS_TEAM_CT)
	return;

Last edited by Doodil; 06-26-2013 at 03:49.
Doodil is offline
Devoo
Junior Member
Join Date: Mar 2013
Old 06-26-2013 , 04:00   Re: Time intervals instead of kills for credits (or certain team kills)
Reply With Quote #3

ill try it out now. And sorry was meant to post the .sp file ill fix it now
Devoo is offline
Marcus_Brown001
AlliedModders Donor
Join Date: Nov 2012
Location: Illinois, United States
Old 06-26-2013 , 11:29   Re: Time intervals instead of kills for credits (or certain team kills)
Reply With Quote #4

How are you doing the credits? I guess what I am asking, more specifically, is that are you just telling the client every 5 minutes what their new credits are, or are you giving them 1 credit, if they killed someone, every 5 minutes?
Marcus_Brown001 is offline
Devoo
Junior Member
Join Date: Mar 2013
Old 06-26-2013 , 20:33   Re: Time intervals instead of kills for credits (or certain team kills)
Reply With Quote #5

preferably it would be every 5 minutes give the client a credit. No matter what which team except if on spectator where they do not get credits.
Devoo is offline
Devoo
Junior Member
Join Date: Mar 2013
Old 06-26-2013 , 20:33   Re: Time intervals instead of kills for credits (or certain team kills)
Reply With Quote #6

Quote:
Originally Posted by Devoo View Post
ill try it out now. And sorry was meant to post the .sp file ill fix it now
Also thanks alot mate, it worked perfectly
Devoo is offline
Reply


Thread Tools
Display Modes

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 01:17.


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