SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 01/10/2011, 06:50 PM   #1
knackworst
Gangsta
 
knackworst's Avatar
 
Join Date: Sep 2010
Location: Belgium
Posts: 913
Reputation: 27
Default Enum Information returns C?

hi, I made my first enum ever...
an enum to easly make missions in my script, instead of adding 50 lines per mission, I try to do it with maybe 5 lines per mission...

anyways this is what I have:
pawn Code:
enum DMissions
{
    mission_name[200],
    person_name[200],
    pick_place[50],
    deliver_place[50],
    mission_type,
    Float:pick_x,
    Float:pick_y,
    Float:pick_z,
    Float:deliver_x,
    Float:deliver_y,
    Float:deliver_z
};

new Mission[6][DMissions]=
{
//==============================================================================
//Mission TYPE 1
//==============================================================================
    {"Travis Pastrana Is Going to participate the X-games", "Travis Pastrana""The Hollywood Hotel",  "The Stadium"1,  \
    334.4390,-1519.8026,35.7015,
    2732.6616,-1841.6346,9.9145},
   
    {"Chris Martin is back from his smash concert in the Stadium VIVA LA VIDA man!",    "Chris Martin", "The Stadium",  "Chris Martin's Hotel",  1, \
    2732.6616,-1841.6346,9.9145,
    1737.9714,-1270.4094,13.5441},
   
//==============================================================================
//Mission TYPE 2
//==============================================================================
   
    {"The Pope has a meeting with Barack Obama",    "The Pope", "The Airport",  "The White House",  2,  \
    1682.4960,-2290.7954,13.0821,
    1122.9896,-2036.9480,69.8938},
   
    {"Herman Van Rompuy, President of Europe has a meeting with Barack Obama""Herman Van Rompuy",    "The Airport",  "The White House",  2,  \
    1682.4960,-2290.7954,13.0821,
    1122.9896,-2036.9480,69.8938},
   
//==============================================================================
//Mission TYPE 3
//==============================================================================
   
    {"Barack Obama has arrived from his trip to Mexico",    "Barack Obama", "The Airport",  "The White House",  3,  \
    1682.4960,-2290.7954,13.0821,
    1122.9896,-2036.9480,69.8938},
   
    {"Rob Dyredek has arrived at the airport""Rob Dyredek""The Airport",  "Dyrdek's House",  3,   \
    1682.4960,-2290.7954,13.0821,
    974.4201,-819.5055,96.6825}
};

ok, so I did not try to make extremely hard functions at the beginning, just some easy stuff to test if I fully understand the way to use this stuff...

ok so the little test code:
pawn Code:
if (strcmp("/mission1", cmdtext, true) == 0)
    {
        new
            string[200],
            mName = Mission[1][mission_name],
            mPName = Mission[1][person_name];
        format(string,sizeof(string),"%s",mName);
        SendClientMessage(playerid, COLOR_YELLOW_LABEL, string);
        format(string,sizeof(string),"%s",mPName);
        SendClientMessage(playerid, COLOR_YELLOW_LABEL, string);
        return 1;
    }

Ok, I compile, and get no errors, so I think that I'm on the good way
but when I go in game i get the following message when I type /mission1

C
CCC

so that means that my first string returned as C
and the second as CCC
... I have no Idea why it gets C...
and why it does not do what it should do...

Thanks in advance
knackworst is offline   Reply With Quote
Old 01/10/2011, 07:01 PM   #2
[MWR]Blood
High-roller
 
Join Date: Apr 2009
Posts: 2,268
Reputation: 105
Default Re: Enum Information returns C?

pawn Code:
if (strcmp("/mission1", cmdtext, true) == 0)
    {
        new
            string[200],
            mName = Mission[sizeof(Mission)][mission_name],
            mPName = Mission[sizeof(Mission)][person_name];
        format(string,sizeof(string),"%s",mName);
        SendClientMessage(playerid, COLOR_YELLOW_LABEL, string);
        format(string,sizeof(string),"%s",mPName);
        SendClientMessage(playerid, COLOR_YELLOW_LABEL, string);
        return 1;
    }
__________________
[MWR]Blood is offline   Reply With Quote
Old 01/10/2011, 07:07 PM   #3
kacper55331
Little Clucker
 
kacper55331's Avatar
 
Join Date: Nov 2010
Posts: 46
Reputation: 1
Default Re: Enum Information returns C?

pawn Code:
format(string,sizeof(string),"%s",Mission[id or int][mission_name]);
pawn Code:
new Mission[6][DMissions]=
{
//==============================================================================
//Mission TYPE 1
//==============================================================================
    {"Travis Pastrana Is Going to participate the X-games", "Travis Pastrana",  "The Hollywood Hotel",  "The Stadium",  1,  \
    334.4390,-1519.8026,35.7015,
    2732.6616,-1841.6346,9.9145},
   
    {"Chris Martin is back from his smash concert in the Stadium VIVA LA VIDA man!",    "Chris Martin", "The Stadium",  "Chris Martin's Hotel",  1, \
    2732.6616,-1841.6346,9.9145,
    1737.9714,-1270.4094,13.5441},
   
//==============================================================================
//Mission TYPE 2
//==============================================================================
   
    {"The Pope has a meeting with Barack Obama",    "The Pope", "The Airport",  "The White House",  2,  \
    1682.4960,-2290.7954,13.0821,
    1122.9896,-2036.9480,69.8938},
   
    {"Herman Van Rompuy, President of Europe has a meeting with Barack Obama",  "Herman Van Rompuy",    "The Airport",  "The White House",  2,  \
    1682.4960,-2290.7954,13.0821,
    1122.9896,-2036.9480,69.8938},
   
//==============================================================================
//Mission TYPE 3
//==============================================================================
   
    {"Barack Obama has arrived from his trip to Mexico",    "Barack Obama", "The Airport",  "The White House",  3,  \
    1682.4960,-2290.7954,13.0821,
    1122.9896,-2036.9480,69.8938},
   
    {"Rob Dyredek has arrived at the airport",  "Rob Dyredek",  "The Airport",  "Dyrdek's House",  3,   \
    1682.4960,-2290.7954,13.0821,
    974.4201,-819.5055,96.6825}
};
I am surprised that the errors do not pop up using: "\"
kacper55331 is offline   Reply With Quote
Old 01/10/2011, 07:10 PM   #4
knackworst
Gangsta
 
knackworst's Avatar
 
Join Date: Sep 2010
Location: Belgium
Posts: 913
Reputation: 27
Default Re: Enum Information returns C?

EDIT: to the first poster
Code:
C:\Users\William\Documents\Famous' World\Famous' World\gamemodes\Famous.pwn(4482) : error 032: array index out of bounds (variable "Mission")
C:\Users\William\Documents\Famous' World\Famous' World\gamemodes\Famous.pwn(4483) : error 032: array index out of bounds (variable "Mission")
lines:
pawn Code:
mName = Mission[sizeof(Mission)][mission_name],
            mPName = Mission[sizeof(Mission)][person_name];

to the second poster:
well the \ stands for new line in PAWN, doesn't it?
I did it because otherwise it's kinda annoying and hard to insert the chords and stuff...
and I don't get the [id or int]
thing...
knackworst is offline   Reply With Quote
Old 01/10/2011, 07:12 PM   #5
[MWR]Blood
High-roller
 
Join Date: Apr 2009
Posts: 2,268
Reputation: 105
Default Re: Enum Information returns C?

Do this:
pawn Code:
new sMission = sizeof(Mission)
and then replace sizeof(Mission) with sMission.
This will fix it.
__________________
[MWR]Blood is offline   Reply With Quote
Old 01/10/2011, 07:14 PM   #6
knackworst
Gangsta
 
knackworst's Avatar
 
Join Date: Sep 2010
Location: Belgium
Posts: 913
Reputation: 27
Default Re: Enum Information returns C?

:O now it returns as serverUnknownCommand ingame...
wtf?

pawn Code:
if (strcmp("/mission1", cmdtext, true) == 0)
    {
        new sMission = sizeof(Mission);
        new
            mName = Mission[sMission][mission_name],
            mPName = Mission[sMission][person_name];
        format(string,sizeof(string),"%s",mName);
        SendClientMessage(playerid, COLOR_YELLOW_LABEL, string);
        format(string,sizeof(string),"%s",mPName);
        SendClientMessage(playerid, COLOR_YELLOW_LABEL, string);
        return 1;
    }
knackworst is offline   Reply With Quote
Old 01/10/2011, 07:16 PM   #7
[MWR]Blood
High-roller
 
Join Date: Apr 2009
Posts: 2,268
Reputation: 105
Default Re: Enum Information returns C?

pawn Code:
if (strcmp("/mission1", cmdtext, true) == 0)
    {
        new sMission = sizeof(Mission);
        format(string,sizeof(string),"%s",Mission[sMission][mission_name]);
        SendClientMessage(playerid, COLOR_YELLOW_LABEL, string);
        format(string,sizeof(string),"%s",Mission[sMission][person_name]);
        SendClientMessage(playerid, COLOR_YELLOW_LABEL, string);
        return 1;
    }
__________________
[MWR]Blood is offline   Reply With Quote
Old 01/10/2011, 07:18 PM   #8
knackworst
Gangsta
 
knackworst's Avatar
 
Join Date: Sep 2010
Location: Belgium
Posts: 913
Reputation: 27
Default Re: Enum Information returns C?

still unknown command thing :/
pawn Code:
if (strcmp("/mission1", cmdtext, true) == 0)
    {
        new sMission = sizeof(Mission);
        format(string,sizeof(string),"%s",Mission[sMission][mission_name]);
        SendClientMessage(playerid, COLOR_YELLOW_LABEL, string);
        format(string,sizeof(string),"%s",Mission[sMission][person_name]);
        SendClientMessage(playerid, COLOR_YELLOW_LABEL, string);
        return 1;
    }
knackworst is offline   Reply With Quote
Old 01/10/2011, 07:23 PM   #9
[MWR]Blood
High-roller
 
Join Date: Apr 2009
Posts: 2,268
Reputation: 105
Default Re: Enum Information returns C?

Well, you have to do this like that:
pawn Code:
new Mission[6][DMissions]=
{
//==============================================================================
//Mission TYPE 1
//==============================================================================
  {var1},
  {var2},
   {var3},
{var4},
//and so on!
__________________
[MWR]Blood is offline   Reply With Quote
Old 01/10/2011, 07:34 PM   #10
knackworst
Gangsta
 
knackworst's Avatar
 
Join Date: Sep 2010
Location: Belgium
Posts: 913
Reputation: 27
Default Re: Enum Information returns C?

but how to i put the info in the variables then? so I can use them later on?
knackworst is offline   Reply With Quote
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] [FS]Information Box ViruZZzZ_ChiLLL Filterscripts 10 18/07/2010 08:04 AM
Information please Berky-Scape Server Support 6 03/05/2010 07:49 PM


All times are GMT. The time now is 07:12 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.