SA-MP Forums Archive
Help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help (/showthread.php?tid=614100)



Help - Zorono - 04.08.2016

Code:
new Events[][][] {
 {"New Year's Day", 1, 1}, // You can add more "Events Text", "Day", "Month"
 {"Martin Luther King Day", 8, 1},
 {"Valentine's Day", 14, 2},
 {"Presidents's Day", 15", 2},
 {"Easter Sunday", 3, 27},
 {"Thomas Jefferson's Birthday", 13, 4},
 {"Mother's Day", 8, 5},
 {"Memorial Day", 30, 5},
 {"Father's Day", 16, 6},
 {"Independence Day" 4, 7},
 {"Labor Day" 5, 9},
 {"Columbos Day", 10, 10},
 {"Halloween", 31, 10},
 {"Election Day", 8, 11},
 {"Veterans Day", 11, 11},
 {"Christmas Eve", 24, 12},
 {"Christmas Day", 25, 12},
 {"Christmas Day Observed", 26, 12},
 {"New Year's Eve", 31, 12};

forward LoadEvents();
public LoadEvents() 
{
new day, month, year;
getdate(day, month, year);

if(day == Events[2] && month == Events[3]){
format(string, sizeof(string), "[BOT]: Happy %s (%02d/%02d)", Events[3], GetDay(day,month), GetMonth(month));
SendClientMessageToAll(-1, string);
}
return 1;
}
Errors:
Code:
(10) : error 009: invalid array size (negative, zero or out of bounds)
(76) : error 033: array must be indexed (variable "Events")
Please help guys


Re: Help - SyS - 04.08.2016

you declared a matrix and using it as linear array


Re: Help - Zorono - 04.08.2016

i don't understand you sir what you mean


Re: Help - WhiteGhost - 04.08.2016

Why use a 3demi for that?

https://sampforum.blast.hk/showthread.php?tid=318212


Re: Help - Zorono - 04.08.2016

Quote:
Originally Posted by WhiteGhost
View Post
i tried all that methods on your tutroial but iam getting the same errors


Re: Help - jlalt - 04.08.2016

you can use it by this way I think its better and easer to read...
PHP Code:
enum EventInfo
{
  
EvName[35],
  
Day,
  
Month,
}
new 
Events[][EventInfo] = {
 {
"New Year's Day"11}, // You can add more "Events Text", "Day", "Month"
 
{"Martin Luther King Day"81},
 {
"Valentine's Day"142},
 {
"Presidents's Day"152},
 {
"Easter Sunday"327},
 {
"Thomas Jefferson's Birthday"134},
 {
"Mother's Day"85},
 {
"Memorial Day"305},
 {
"Father's Day"166},
 {
"Independence Day"47},
 {
"Labor Day"59},
 {
"Columbos Day"1010},
 {
"Halloween"3110},
 {
"Election Day"811},
 {
"Veterans Day"1111},
 {
"Christmas Eve"2412},
 {
"Christmas Day"2512},
 {
"Christmas Day Observed"2612},
 {
"New Year's Eve"3112}
};
forward LoadEvents();
public 
LoadEvents()
{
   new 
daymonthyear;
   
getdate(daymonthyear);
   for(new 
0sizeof Eventsi++)
   {
      if(
day == Events[i][Day] && month == Events[i][Month]){
         new 
string[80];
         
format(stringsizeof(string), "[BOT]: Happy %s (%02d/%02d)"Events[i][EvName], GetDay(day,month), GetMonth(month));
         
SendClientMessageToAll(-1string);
      }
      break;
   }
   return 
1;

Edit: Thanks Stinged, fixed.


Re: Help - Stinged - 04.08.2016

Code:
enum e_Events
{
    Name[28],
    Day,
    Month
};

new Events[][e_Events] =
{
    {"New Year's Day", 1, 1},
    {"Martin Luther King Day", 8, 1},
    {"Valentine's Day", 14, 2},
    {"Presidents's Day", 15, 2},
    {"Easter Sunday", 3, 27},
    {"Thomas Jefferson's Birthday", 13, 4},
    {"Mother's Day", 8, 5},
    {"Memorial Day", 30, 5},
    {"Father's Day", 16, 6},
    {"Independence Day" 4, 7},
    {"Labor Day" 5, 9},
    {"Columbos Day", 10, 10},
    {"Halloween", 31, 10},
    {"Election Day", 8, 11},
    {"Veterans Day", 11, 11},
    {"Christmas Eve", 24, 12},
    {"Christmas Day", 25, 12},
    {"Christmas Day Observed", 26, 12},
    {"New Year's Eve", 31, 12}
};

forward LoadEvents();
public LoadEvents() 
{
    new day, month, year;
    getdate(day, month, year);


    for (new i = 0; i < sizeof (Events); i++)
    {
        if(day == Events[i][Day] && month == Events[i][Month])
        {
            format(string, sizeof(string), "[BOT]: Happy %s (%02d/%02d)", Events[i][Name], GetDay(day, month), GetMonth(month));
            SendClientMessageToAll(-1, string);
            break;
        }
    }
    return 1;
}
Quote:
Originally Posted by WhiteGhost
View Post
Why use a 3demi for that?
I think you mean dime and not demi.

EDIT: jlalt was faster, but you should break the loop once you have found the date.
No need to keep looping for no reason.


Re: Help - Zorono - 04.08.2016

Quote:
Originally Posted by jlalt
View Post
you can use it by this way I think its better and easer to read...
PHP Code:
enum EventInfo
{
  
EvName[35],
  
Day,
  
Month,
}

new 
Events[][EventInfo] = {
 {
"New Year's Day"11}, // You can add more "Events Text", "Day", "Month"
 
{"Martin Luther King Day"81},
 {
"Valentine's Day"142},
 {
"Presidents's Day"152},
 {
"Easter Sunday"327},
 {
"Thomas Jefferson's Birthday"134},
 {
"Mother's Day"85},
 {
"Memorial Day"305},
 {
"Father's Day"166},
 {
"Independence Day"47},
 {
"Labor Day"59},
 {
"Columbos Day"1010},
 {
"Halloween"3110},
 {
"Election Day"811},
 {
"Veterans Day"1111},
 {
"Christmas Eve"2412},
 {
"Christmas Day"2512},
 {
"Christmas Day Observed"2612},
 {
"New Year's Eve"3112}
};

forward LoadEvents();
public 
LoadEvents()
{
   new 
daymonthyear;
   
getdate(daymonthyear);
   for(new 
0sizeof Eventsi++)
   {
      if(
day == Events[i][Day] && month == Events[i][Month]){
         new 
string[80];
         
format(stringsizeof(string), "[BOT]: Happy %s (%02d/%02d)"Events[i][EvName], GetDay(day,month), GetMonth(month));
         
SendClientMessageToAll(-1string);
      }
      break;
   }
   return 
1;

Edit: Thanks Stinged, fixed.
Quote:
Originally Posted by Stinged
View Post
Code:
enum e_Events
{
    Name[28],
    Day,
    Month
};

new Events[][e_Events] =
{
    {"New Year's Day", 1, 1},
    {"Martin Luther King Day", 8, 1},
    {"Valentine's Day", 14, 2},
    {"Presidents's Day", 15, 2},
    {"Easter Sunday", 3, 27},
    {"Thomas Jefferson's Birthday", 13, 4},
    {"Mother's Day", 8, 5},
    {"Memorial Day", 30, 5},
    {"Father's Day", 16, 6},
    {"Independence Day" 4, 7},
    {"Labor Day" 5, 9},
    {"Columbos Day", 10, 10},
    {"Halloween", 31, 10},
    {"Election Day", 8, 11},
    {"Veterans Day", 11, 11},
    {"Christmas Eve", 24, 12},
    {"Christmas Day", 25, 12},
    {"Christmas Day Observed", 26, 12},
    {"New Year's Eve", 31, 12}
};

forward LoadEvents();
public LoadEvents() 
{
    new day, month, year;
    getdate(day, month, year);


    for (new i = 0; i < sizeof (Events); i++)
    {
        if(day == Events[i][Day] && month == Events[i][Month])
        {
            format(string, sizeof(string), "[BOT]: Happy %s (%02d/%02d)", Events[i][Name], GetDay(day, month), GetMonth(month));
            SendClientMessageToAll(-1, string);
            break;
        }
    }
    return 1;
}

I think you mean dime and not demi.

EDIT: jlalt was faster, but you should break the loop once you have found the date.
No need to keep looping for no reason.
Thanks Guys your helps solved my proplem