Compatible/Suggested Login Rewards

Gameplay Addons
Post Reply
User avatar
Muhammet20
Veteran Member
Veteran Member
Syria
Posts: 358
Joined: 11 Months Ago
Location: Turkey
Has thanked: 36 times
Been thanked: 5 times
Age: 13
Contact:

Login Rewards

#1

Post by Muhammet20 » 1 Month Ago

Hi All,
This Plugin Is Gives You 500 Escape Coins When You Login Every 24 Hour(1 Day)
You Can Change The Ammount Of Escape Coins Or The Time For Login

Plugin Code:

Code: Select all

#include <zombie_escape>

#define NV_NAME "daily_login_data"

enum player_struct {
    mtime,bool:ftime,key[64]
}
new g_player[33][player_struct];

new cvar_save_type,cvar_time,cvar_ec;
new g_MaxPlayers

public plugin_init() 
{

    register_plugin("Login reward", "1.0", "Kaya Gaming");
    
    cvar_save_type = register_cvar("get_ammo_save_type","3"); // how to save data 1 by authid, 2 by ip or 3 by name
    cvar_time = register_cvar("get_ammo_minutes","1440"); // time in minutes, 720minutes=12hours it will be auto calculated
    cvar_ec = register_cvar("ze_daily_login_reward_ec","500"); // how many ammo packs to give
    
    g_MaxPlayers = get_maxplayers();
}
public client_connect(id)
{
	set_task(4.5,"cmd_ec",id)
}
public cmd_ec(id) 
{
if(get_user_xp(id) < 300000)
{
    new nv = nvault_open(NV_NAME);
    
    if(nv == INVALID_HANDLE) {
        client_print(id,print_chat,"Reloading System.....");
        return;
    }
    
    new txt_min[32],txt_ec[10];
    new ec = get_pcvar_num(cvar_ec),pminutes = get_pcvar_num(cvar_time);
    copy(txt_ec,charsmax(txt_ec),(ec==1)?"pack":"packs");
    build_time(pminutes,txt_min,charsmax(txt_min));
    
    if(g_player[id][ftime]) {
        client_printc(id,"!n[!gZombie Escape!n] !nThanks for !tlogin today!n,!gyou won %d Escape Coins !nlogin again tommorow to !twin more!n.",cvar_ec);
        ze_set_user_escape_coins(id, ze_get_user_escape_coins(id)+ec);
        g_player[id][ftime]=false;
        nvault_touch(nv,g_player[id][key],g_player[id][mtime]=get_systime());
        return;
    }
    new user_time=get_systime()-g_player[id][mtime];
    new diff_min=(user_time<(pminutes*60))?pminutes-(user_time/60):pminutes;
    build_time(diff_min,txt_min,charsmax(txt_min));
    
    if(user_time>=(pminutes*60)) 
    {
        client_printc(id,"!n[!gZombie Escape!n] !nThanks for !tlogin today!n,!gyou won %d Escape Coins !nlogin again tommorow to !twin more!n.",cvar_ec);
        ze_set_user_escape_coins(id, ze_get_user_escape_coins(id)+ec);
        nvault_touch(nv,g_player[id][key],g_player[id][mtime]=get_systime());
    }
    nvault_close(nv);
}
}
public client_putinserver(id) {
        
    new nv,data[32];
    get_auth(id,g_player[id][key],charsmax(g_player[][key]));
    g_player[id][mtime]=get_systime();
    g_player[id][ftime]=false;
    formatex(data,charsmax(data),"%d",g_player[id][mtime]);
    
    if((nv=nvault_open(NV_NAME))==INVALID_HANDLE)
        return;
    
    if(!nvault_lookup(nv,g_player[id][key],data,charsmax(data),g_player[id][mtime])) {
        nvault_set(nv,g_player[id][key],data);
        g_player[id][ftime]=true;
    }
    
    nvault_close(nv);
 
}    

public client_disconnect(id) {
    
    g_player[id][mtime]=0;
    g_player[id][ftime]=false;
}

stock get_auth(id,data[],len)
    switch(get_pcvar_num(cvar_save_type)) {
        case 1: get_user_authid(id,data,len);
        case 2: get_user_ip(id,data,len,1);
        case 3: get_user_name(id,data,len);
    }

stock build_time(pminutes,data[],len)
{
    if(pminutes==1)
        copy(data,len,"1 minute");
    else if(pminutes!=1&&pminutes<60)
        formatex(data,len,"%d minutes",pminutes);
    else if(pminutes==60)
        copy(data,len,"1 hour");
    else {
        new ptime=pminutes/60;
        if(ptime*60==pminutes)
            formatex(data,len,"%d %s",ptime,(ptime==1)?"hour":"hours");
        else {
            new diff=pminutes-ptime*60;
            formatex(data,len,"%d %s and %d %s",ptime,(ptime==1)?"hour":"hours",diff,(diff==1)?"minute":"minutes");
       }
   }
}
stock client_printc(index, const text[], any:...)
{
	new szMsg[128];
	vformat(szMsg, sizeof(szMsg) - 1, text, 3);
	
	replace_all(szMsg, sizeof(szMsg) - 1, "!g", "^x04");
	replace_all(szMsg, sizeof(szMsg) - 1, "!n", "^x01");
	replace_all(szMsg, sizeof(szMsg) - 1, "!t", "^x03");
	
	if(index == 0)
	{
		for(new i = 0; i < g_MaxPlayers; i++)
		{
			if(is_user_alive(i) && is_user_connected(i))
			{
				message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, i);
				write_byte(i);
				write_string(szMsg);
				message_end();	
			}
		}		
		} else {
		message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, index);
		write_byte(index);
		write_string(szMsg);
		message_end();
	}
} 
.::Kaya Gaming || Never Give Up || Zombie Escape::.
https://kaya-gaming.ga/index.php

I just believe in two things, First thing is who i see in the mirror, second thing is who i don't see in the sky.

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 508
Joined: 2 Years Ago
Has thanked: 19 times
Been thanked: 1 time
Contact:

#2

Post by czirimbolo » 1 Month Ago

Image

User avatar
Muhammet20
Veteran Member
Veteran Member
Syria
Posts: 358
Joined: 11 Months Ago
Location: Turkey
Has thanked: 36 times
Been thanked: 5 times
Age: 13
Contact:

#3

Post by Muhammet20 » 1 Month Ago

but this not like this
my plugin is give you escape coins automaticly when you connect in the last 24 hours
no need to say /get when you are playing
.::Kaya Gaming || Never Give Up || Zombie Escape::.
https://kaya-gaming.ga/index.php

I just believe in two things, First thing is who i see in the mirror, second thing is who i don't see in the sky.

User avatar
Muhammet20
Veteran Member
Veteran Member
Syria
Posts: 358
Joined: 11 Months Ago
Location: Turkey
Has thanked: 36 times
Been thanked: 5 times
Age: 13
Contact:

#4

Post by Muhammet20 » 1 Month Ago

Raheem can you Approve please if you don't have a problem ?
.::Kaya Gaming || Never Give Up || Zombie Escape::.
https://kaya-gaming.ga/index.php

I just believe in two things, First thing is who i see in the mirror, second thing is who i don't see in the sky.

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1958
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 21
Contact:

#5

Post by Raheem » 1 Month Ago

Have no time to read the code, will be marked as compatible.

[ Post made via Android ]
These users thanked the author Raheem for the post:
Muhammet20 (1 Month Ago)
You don't know? Learn and you will know.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests