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

Stock problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 08-22-2013 , 12:27   Stock problem
Reply With Quote #1

Hi
This is first stock i try to do so dont put a gun in my head please

PHP Code:
public set_age(idlevelcid)
{
    if(!
cmd_access(idlevelcid4))
        return

    new 
age_day[3], age_month[3], age_year[5]
    
read_argv(1age_day2)
    
read_argv(2age_month2)
    
read_argv(3age_year4)
    
    
str_to_num(age_day)
    
str_to_num(age_month)
    
str_to_num(age_year)
    
    
set_user_age(idage_yearage_monthage_day)
}

stock set_user_age(idage_yearage_monthage_day)
{
    new 
today_year[5], today_month[3], today_day[3]
    
get_time("%Y"today_year4)
    
get_time("%m"today_month2)
    
get_time("%d"today_day2)
    
    if(
today_year age_year)
        return
    
    
age[id] = today_year age_year
    
    
if(today_month <= age_month)
    {
        if(
today_month == age_month && today_day age_day || today_month age_month)
            
age[id] -= 1
    
}
    
    if(
today_month == age_month && today_day == age_day)
        
in_birthday[id] = true

well i have no idea what is the problem

Errors:
Code:
Error: Argument type mismatch (argument 2) on line 66
Error: Array must be indexed (variable "today_year") on line 76
Error: Array must be indexed (variable "today_year") on line 79
Error: Array must be indexed (variable "today_month") on line 81
Error: Array must be indexed (variable "today_month") on line 83
Error: Array must be indexed (variable "today_month") on line 87
If i delete function set_age, the stock doesnt gets any error.
__________________
Jhob94 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-22-2013 , 12:48   Re: Stock problem
Reply With Quote #2

today_year - age_year

You can't do that with string. You have to convert them before in integer number, for example with str_to_num().
__________________
Arkshine is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 08-22-2013 , 13:10   Re: Stock problem
Reply With Quote #3

lol forgot to convert it
Anyway that isnt the problem here...
__________________
Jhob94 is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 08-22-2013 , 13:18   Re: Stock problem
Reply With Quote #4

Code:
set_user_age(id, str_to_num(age_year), str_to_num(age_month), str_to_num(age_day))
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 08-22-2013 , 14:01   Re: Stock problem
Reply With Quote #5

PHP Code:
stock set_user_age(idage_yearage_monthage_day)
{
    new 
a[5], b[3], c[3], today_yeartoday_monthtoday_day
    get_time
("%Y"a 4)
    
get_time("%m"b2)
    
get_time("%d"c2)
    
today_year str_to_num(a)
    
today_month str_to_num(b)
    
today_day str_to_num(c)
    if(
age_year >= today_year) return
    
age[id] = today_year age_year
    age
[id] = today_year age_year
    
if(today_year == age_year && today_month == age_month && today_day == age_dayin_birthday[id] = true

should be fine.

Last edited by .Dare Devil.; 08-22-2013 at 14:03.
.Dare Devil. is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 08-22-2013 , 15:40   Re: Stock problem
Reply With Quote #6

thanks guys
__________________
Jhob94 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-23-2013 , 00:36   Re: Stock problem
Reply With Quote #7

PHP Code:
stock set_user_age(idage_yearage_monthage_day
This stock should be named "check _user_age" or check_user_birthday or whatever, but not set_*
Also, if you pass strings to this stock, it should looks like :

PHP Code:
stock set_user_age(idage_year[], age_month[], age_day[]) 
or

PHP Code:
stock set_user_age(idage_year[32], age_month[32], age_day[32]) 
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 08-23-2013 , 13:27   Re: Stock problem
Reply With Quote #8

Well it runs good but now chat has a problem

PHP Code:
public hook_say(id)
{
    if(
age[id] >= MIN_AGE)
    {
        static 
say[192]
        
read_args(saycharsmax(say))
        
remove_quotes(say)
    
        
replace_all(saycharsmax(say), "%"" ")
    
        if(
equali(say""))
            return 
PLUGIN_HANDLED
            
        
if(equali(say"/agehelp"))
            
ShowMotd(id)
    
        static 
name[33]; get_user_name(idnamecharsmax(name))
    
        for(new 
index 1index <= g_MaxPlayersindex++)
        {
            if(
is_user_alive(id) && is_user_alive(index))
            {
                if(
in_birthday[id])
                    
ColorChat(indexGREEN"[BIRTHDAY %d Years] ^x03%s^x01: %s"age[id], namesay)
                
                else
                    
ColorChat(indexGREEN"[%d Years] ^x03%s^x01: %s"age[id], namesay)
            }
            
            if(!
is_user_alive(id) && !is_user_alive(index))
            {
                if(
in_birthday[id])
                    
ColorChat(indexYELLOW"*DEAD* ^x04[BIRTHDAY %d Years] ^x03%s^x01: %s"age[id], namesay)
                
                else
                    
ColorChat(indexYELLOW"*DEAD* ^x04[%d Years] ^x03%s^x01: %s"age[id], namesay)
            }
        }
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE
}

// Color Messages

stock ColorChat(idColor:type, const msg[], {Float,Sql,Result,_}:...)
{
    static 
message[256];

    switch(
type)
    {
        case 
YELLOW// Yellow
        
{
            
message[0] = 0x01;
        }
        case 
GREEN// Green
        
{
            
message[0] = 0x04;
        }
        default: 
// White, Red, Blue
        
{
            
message[0] = 0x03;
        }
    }

    
vformat(message[1], 251msg4);

    
message[192] = '^0';

    new 
teamColorChangeindexMSG_Type;
    
    if(!
id)
    {
        
index FindPlayer();
        
MSG_Type MSG_ALL;
    
    } else {
        
MSG_Type MSG_ONE;
        
index id;
    }
    
    
team get_user_team(index);    
    
ColorChange ColorSelection(indexMSG_Typetype);

    
ShowColorMessage(indexMSG_Typemessage);
        
    if(
ColorChange)
    {
        
Team_Info(indexMSG_TypeTeamName[team]);
    }
}

ShowColorMessage(idtypemessage[])
{
    
message_begin(typeg_msgSayText_id);
    
write_byte(id)        
    
write_string(message);
    
message_end();    
}

Team_Info(idtypeteam[])
{
    
message_begin(typeg_TeamInfo_id);
    
write_byte(id);
    
write_string(team);
    
message_end();

    return 
1;
}

ColorSelection(indextypeColor:Type)
{
    switch(
Type)
    {
        case 
RED:
        {
            return 
Team_Info(indextypeTeamName[1]);
        }
        case 
BLUE:
        {
            return 
Team_Info(indextypeTeamName[2]);
        }
        case 
GREY:
        {
            return 
Team_Info(indextypeTeamName[0]);
        }
    }

    return 
0;
}

FindPlayer()
{
    new 
= -1;

    while(
<= g_MaxPlayers)
    {
        if(
IsConnected[++i])
        {
            return 
i;
        }
    }

    return -
1;

Chat when alive works good but if dead chat, it shutdown the server. Error:
Code:
MSG_ONE or MSG_ONE_UNRELIABLE with no target entity
The chat stock i found somewhere in tutorials/snipets forum, so i think that nothing is wrong with it
__________________
Jhob94 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-23-2013 , 13:39   Re: Stock problem
Reply With Quote #9

LOL
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 08-23-2013 , 13:44   Re: Stock problem
Reply With Quote #10

I should use the plugin in your signature
But i get confused with your colorchat usage because of the second argument
__________________
Jhob94 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 15:51.


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