Raised This Month: $ Target: $400
 0% 

Played time bonus.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Skyliner
Member
Join Date: Sep 2011
Location: Fagaras
Old 04-05-2015 , 05:36   Played time bonus.
Reply With Quote #1

Hello again, what i want?
I have a WAR3FT server .. and i have gold system on it .. what is that?
Ok, so, if you type /trade you can change your gold with money or experience on server ..
The gold you will receive after 5 - 10 kils ...

So what i want?
I want a plugin that after 30 minutes (for example) of playing on server to give you 1 gold (i have a command on server, amx_givegold to give gold to a player), and again after 30 minutes another 2 gold, and again after 30 minutes 3 gold and so on ...

Quote:
#include <amxmodx>
#include <cstrike>
#include <nvault>

#define MM_HOUR 3600

enum ChatColor
{
CHATCOLOR_NORMAL = 1,
CHATCOLOR_GREEN,
CHATCOLOR_TEAM_COLOR,
CHATCOLOR_GREY,
CHATCOLOR_RED,
CHATCOLOR_BLUE,
}

new g_TeamName[][] =
{
"",
"TERRORIST",
"CT",
"SPECTATOR"
}

new g_msgSayText
new g_msgTeamInfo

new const gNazwaPluginu[] = "Play Time Bonus";
new const gWersjaPluginu[] = "0.1";
new const gAutorPluginu[] = "MisieQ";

new pcvar_pt, pcvar_pt_bonus, pcvar_pt_bonus_1h, pcvar_pt_bonus_2h, pcvar_pt_bonus_3h, pcvar_pt_bonus_4h, pcvar_pt_bonus_5h
new g_Vault

public plugin_init()
{
register_plugin(gNazwaPluginu, gWersjaPluginu, gAutorPluginu);

pcvar_pt = register_cvar("pt_enabled", "1")
pcvar_pt_bonus = register_cvar("pt_bonus", "1")
pcvar_pt_bonus_1h = register_cvar("pt_bonus_1h", "250")
pcvar_pt_bonus_2h = register_cvar("pt_bonus_2h", "500")
pcvar_pt_bonus_3h = register_cvar("pt_bonus_3h", "1000")
pcvar_pt_bonus_4h = register_cvar("pt_bonus_4h", "2000")
pcvar_pt_bonus_5h = register_cvar("pt_bonus_5h", "5000")

register_event("SendAudio", "eventEndRound", "a", "2=%!MRAD_terwin", "2=%!MRAD_ctwin", "2=%!MRAD_rounddraw")

g_msgSayText = get_user_msgid("SayText")
g_msgTeamInfo = get_user_msgid("TeamInfo")
}

public plugin_cfg()
{
if(get_pcvar_num(pcvar_pt))
{
g_Vault = nvault_open("play_time")

if(g_Vault == INVALID_HANDLE)
{
set_fail_state("Error opening nVault")
}

nvault_prune(g_Vault , 0 , get_systime() - (30 * 86400 ))
}
}

public plugin_end()
{
if(get_pcvar_num(pcvar_pt))
{
nvault_close(g_Vault)
}
}

public client_disconnect(id)
{
if(get_pcvar_num(pcvar_pt))
{
played_time(id)
}
}

public eventEndRound()
{
time_play_bonus()
}

public played_time(id)
{
new szPlayers[32], iNum, szKey[32], szData[128], szName[32]

new szMinute[5], szHour[5], szDay[5], szMonth[5], szYear[5]
new iMinute, iHour, iDay, iMonth, iYear

format_time(szMinute, sizeof(szMinute) - 1, "%M")
format_time(szHour, sizeof(szHour) - 1, "%H")
format_time(szDay, sizeof(szDay) - 1, "%d")
format_time(szMonth, sizeof(szMonth) - 1, "%m")
format_time(szYear, sizeof(szYear) - 1, "%Y")

iMinute = str_to_num(szMinute)
iHour = str_to_num(szHour)
iDay = str_to_num(szDay)
iMonth = str_to_num(szMonth)
iYear = str_to_num(szYear)

get_players(szPlayers, iNum)

get_user_name(id, szName, sizeof(szName) - 1)
formatex(szKey, sizeof(szKey) - 1, "PLAYED_TIME#%s", szName)

nvault_get(g_Vault, szKey, szData, sizeof(szData) - 1)

new iTime = str_to_num(szData)

formatex(szData, sizeof(szData) - 1, "%d", iTime + (get_user_time(id)))

nvault_set(g_Vault , szKey, szData)

formatex(szKey, sizeof(szKey) - 1, "LAST_VISIT#%s", szName)
formatex(szData, sizeof(szData) - 1, "%d %d %d %d %d", iDay, iMonth, iYear,iHour, iMinute)
nvault_set(g_Vault , szKey, szData)

formatex(szKey, sizeof(szKey) - 1, "TODAY_PLAY#%s", szName)
nvault_get(g_Vault, szKey, szData, sizeof(szData) - 1)

new szToday[5], szTodayPlay[256]
parse(szData, szToday, sizeof(szToday), szTodayPlay, sizeof(szTodayPlay))

if(str_to_num(szToday) != iDay)
{
formatex(szData, sizeof(szData) - 1, "%d 0", iDay)
nvault_set(g_Vault , szKey, szData)
}
else
{
formatex(szData, sizeof(szData) - 1, "%d %d", iDay, (get_user_time(id) + str_to_num(szTodayPlay)))
nvault_set(g_Vault , szKey, szData)
}
}

public time_play_bonus()
{
if(!get_pcvar_num(pcvar_pt_bonus) || !get_pcvar_num(pcvar_pt))
{
return PLUGIN_HANDLED
}

new iCash, iTmpCash, iDay, szDay[5]
new szPlayers[32], iNum, szName[32]
new szKey[50], szData[128]

new iCash_1h = get_pcvar_num(pcvar_pt_bonus_1h)
new iCash_2h = get_pcvar_num(pcvar_pt_bonus_2h)
new iCash_3h = get_pcvar_num(pcvar_pt_bonus_3h)
new iCash_4h = get_pcvar_num(pcvar_pt_bonus_4h)
new iCash_5h = get_pcvar_num(pcvar_pt_bonus_5h)

format_time(szDay, sizeof(szDay) - 1, "%d")
iDay = str_to_num(szDay)

get_players(szPlayers, iNum)
for(new i = 0; i < iNum; i++)
{
if(cs_get_user_team(szPlayers[i]) == CS_TEAM_SPECTATOR)
{
continue
}

get_user_name(szPlayers[i], szName, sizeof(szName) - 1)
formatex(szKey, sizeof(szKey) - 1, "TODAY_PLAY#%s", szName)
nvault_get(g_Vault, szKey, szData, sizeof(szData) - 1)

new szToday[5], szTodayPlay[256]
parse(szData, szToday, sizeof(szToday), szTodayPlay, sizeof(szTodayPlay))

if(iDay != str_to_num(szToday))
{
formatex(szData, sizeof(szData) - 1, "%d 0", iDay)
nvault_set(g_Vault, szKey, szData)

continue
}

new iTime = (get_user_time(szPlayers[i]) + str_to_num(szTodayPlay)) / MM_HOUR

iCash = cs_get_user_money(szPlayers[i])

if(!iTime)
{
continue
}

if(iTime == 1 && iCash_1h != 0)
{
if((iCash + iCash_1h) > 16000)
{
cs_set_user_money(szPlayers[i], 16000)
}
else
{
cs_set_user_money(szPlayers[i], iCash + iCash_1h)
}
iTmpCash = iCash_1h
}

if(iTime == 2 && iCash_2h != 0)
{
if((iCash + iCash_2h) > 16000)
{
cs_set_user_money(szPlayers[i], 16000)
}
else
{
cs_set_user_money(szPlayers[i], iCash + iCash_2h)
}
iTmpCash = iCash_2h
}

if(iTime == 3 && iCash_3h != 0)
{
if((iCash + iCash_3h) > 16000)
{
cs_set_user_money(szPlayers[i], 16000)
}
else
{
cs_set_user_money(szPlayers[i], iCash + iCash_3h)
}
iTmpCash = iCash_3h
}

if(iTime == 4 && iCash_4h != 0)
{
if((iCash + iCash_4h) > 16000)
{
cs_set_user_money(szPlayers[i], 16000)
}
else
{
cs_set_user_money(szPlayers[i], iCash + iCash_4h)
}
iTmpCash = iCash_4h
}

if(iTime > 5 && iCash_5h != 0)
{
if((iCash + iCash_5h) > 16000)
{
cs_set_user_money(szPlayers[i], 16000)
}
else
{
cs_set_user_money(szPlayers[i], iCash + iCash_5h)
}
iTmpCash = iCash_5h
}

colorChat(szPlayers[i], CHATCOLOR_GREEN, "Grasz juz u nas $t%d h.$g dlatego dostajesz $t%d$$g bonusu", iTime, iTmpCash)


}

return PLUGIN_HANDLED
}

colorChat(id, ChatColor:color, const msg[], {Float,Sql,Result,_}:...)
{
new team, index, MSG_Type
new bool:teamChanged = false
static message[192]

switch(color)
{
case CHATCOLOR_NORMAL: // Normal
{
message[0] = 0x01;
}
case CHATCOLOR_GREEN: // Green
{
message[0] = 0x04;
}
default: // Grey, Red, Blue
{
message[0] = 0x03;
}
}

vformat(message[1], 190, msg, 4);
replace_all(message, 190, "$g", "^x04")
replace_all(message, 190, "$n", "^x01")
replace_all(message, 190, "$t", "^x03")

if(id == 0)
{
index = findAnyPlayer();
MSG_Type = MSG_ALL;
}
else
{
index = id;
MSG_Type = MSG_ONE;
}
if(index != 0)
{
team = get_user_team(index);
if(color == CHATCOLOR_RED && team != 1)
{
messageTeamInfo(index, MSG_Type, g_TeamName[1])
teamChanged = true
}
else
if(color == CHATCOLOR_BLUE && team != 2)
{
messageTeamInfo(index, MSG_Type, g_TeamName[2])
teamChanged = true
}
else
if(color == CHATCOLOR_GREY && team != 0)
{
messageTeamInfo(index, MSG_Type, g_TeamName[0])
teamChanged = true
}
messageSayText(index, MSG_Type, message);
if(teamChanged)
{
messageTeamInfo(index, MSG_Type, g_TeamName[team])
}
}
}

messageSayText(id, type, message[])
{
message_begin(type, g_msgSayText, _, id)
write_byte(id)
write_string(message)
message_end()
}

messageTeamInfo(id, type, team[])
{
message_begin(type, g_msgTeamInfo, _, id)
write_byte(id)
write_string(team)
message_end()
}

findAnyPlayer()
{
static players[32], inum, pid

get_players(players, inum, "ch")

for (new a = 0; a < inum; a++)
{
pid = players[a]
if(is_user_connected(pid))
return pid
}

return 0
}

I have managed to find something similar but it's with money .. can you guys please help me to make this plugin? Thanks! and sry for my bad english .
__________________

Skyliner is offline
Send a message via Yahoo to Skyliner Send a message via Skype™ to Skyliner
 



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 09:38.


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