SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 16/12/2018, 10:53 AM   #1
DarkMythHunter
Big Clucker
 
Join Date: May 2017
Location: Philippines
Posts: 140
Reputation: 24
Default Invalid function or declaration

Code:
Utils/Zombies.pwn(87) : error 010: invalid function or declaration
Utils/Zombies.pwn(89) : error 010: invalid function or declaration
Utils/Zombies.pwn(91) : error 010: invalid function or declaration
Utils/Zombies.pwn(92) : error 010: invalid function or declaration
Utils/Zombies.pwn(93) : error 010: invalid function or declaration
Utils/Zombies.pwn(94) : error 010: invalid function or declaration
Utils/Zombies.pwn(95) : error 010: invalid function or declaration
Utils/Zombies.pwn(96) : error 010: invalid function or declaration
Utils/Zombies.pwn(97) : error 010: invalid function or declaration
Utils/Zombies.pwn(98) : error 010: invalid function or declaration
Utils/Zombies.pwn(99) : error 010: invalid function or declaration
Utils/Zombies.pwn(100) : error 010: invalid function or declaration
Utils/Zombies.pwn(101) : error 010: invalid function or declaration
Utils/Zombies.pwn(102) : error 010: invalid function or declaration
Utils/Zombies.pwn(103) : error 010: invalid function or declaration
Utils/Zombies.pwn(104) : error 010: invalid function or declaration
Utils/Zombies.pwn(105) : error 010: invalid function or declaration
Utils/Zombies.pwn(106) : error 010: invalid function or declaration
Utils/Zombies.pwn(107) : error 010: invalid function or declaration
Utils/Zombies.pwn(108) : error 010: invalid function or declaration
Utils/Zombies.pwn(109) : error 010: invalid function or declaration
Utils/Zombies.pwn(110) : error 010: invalid function or declaration
Utils/Zombies.pwn(111) : error 010: invalid function or declaration
Utils/Zombies.pwn(112) : error 010: invalid function or declaration
Utils/Zombies.pwn(113) : error 010: invalid function or declaration
Utils/Zombies.pwn(114) : error 010: invalid function or declaration
PHP Code:
            default :
            {
                switch(
random(25))
                {
                    case 
0zInfo[o][zItem] = ITEM_ID_CIVILIAN_SKIN;
                    case 
1zInfo[o][zItem] = ITEM_ID_KNIFE;
                    case 
2zInfo[o][zItem] = ITEM_ID_GOLF_CLUB;
                    case 
3zInfo[o][zItem] = ITEM_ID_GAS_CAN;
                    case 
4zInfo[o][zItem] = ITEM_ID_LIGHTER;
                    case 
5zInfo[o][zItem] = ITEM_ID_MATCHES;
                    case 
6zInfo[o][zItem] = ITEM_ID_WATCH;
                    case 
7zInfo[o][zItem] = ITEM_ID_ROPE;
                    case 
8zInfo[o][zItem] = ITEM_ID_FISHING_ROD;
                    case 
9zInfo[o][zItem] = ITEM_ID_GAS_MASK;
                    case 
10zInfo[o][zItem] = ITEM_ID_MOTOCROSS_HELMET;
                    case 
11zInfo[o][zItem] = ITEM_ID_CROWBAR;
                    case 
12zInfo[o][zItem] = Iter_Random(Item_Food);
                    case 
13zInfo[o][zItem] = ITEM_ID_WOOD;
                    case 
14zInfo[o][zItem] = ITEM_ID_CLOTH;
                    case 
15zInfo[o][zItem] = ITEM_ID_RUBBER;
                    case 
16zInfo[o][zItem] = ITEM_ID_EMPTY_WATER_BOTTLE;
                    case 
17zInfo[o][zItem] = ITEM_ID_EMPTY_JERRY_CAN;
                    case 
18zInfo[o][zItem] = ITEM_ID_DRYBAG;
                    case 
19zInfo[o][zItem] = ITEM_ID_ALICE_BACKPACK;
                    case 
20zInfo[o][zItem] = ITEM_ID_SUICEPACK;
                    case 
21zInfo[o][zItem] = ITEM_ID_BAIT;
                    case 
22zInfo[o][zItem] = ITEM_ID_CIGARETTE;
                    case 
23zInfo[o][zItem] = ITEM_ID_PACKCIGARRETES;
                    case 
24zInfo[o][zItem] = ITEM_ID_DIRTY_WATER_BOTTLE;
                }
            } 

Anyone knows what is the problem? Is it because of the "default"? Because the other one uses "case <skin id> : " and it works fine, it is just this part of the script which uses "default".
DarkMythHunter is offline   Reply With Quote
Old 16/12/2018, 10:58 AM   #2
Kaliber
Gangsta
 
Kaliber's Avatar
 
Join Date: Jun 2012
Location: Localhost
Posts: 997
Reputation: 136
Default Re: Invalid function or declaration

Can you show, how you declared these things?
__________________
Kaliber is offline   Reply With Quote
Old 16/12/2018, 11:00 AM   #3
DarkMythHunter
Big Clucker
 
Join Date: May 2017
Location: Philippines
Posts: 140
Reputation: 24
Default Re: Invalid function or declaration

Quote:
Originally Posted by Kaliber View Post
Can you show, how you declared these things?

Is this what you mean?


PHP Code:
CODE REMOVED 

Last edited by DarkMythHunter; 16/12/2018 at 01:12 PM.
DarkMythHunter is offline   Reply With Quote
Old 16/12/2018, 12:52 PM   #4
Threshold
High-roller
 
Threshold's Avatar
 
Join Date: Nov 2012
Location: Australia
Posts: 3,088
Reputation: 519
Default Re: Invalid function or declaration

We need to see where you define zInfo and preferably the enumerator you use in it.
__________________

Kar's Cops and Robbers 2019
Threshold is offline   Reply With Quote
Old 16/12/2018, 01:13 PM   #5
DarkMythHunter
Big Clucker
 
Join Date: May 2017
Location: Philippines
Posts: 140
Reputation: 24
Default Re: Invalid function or declaration

PHP Code:
new str[14], _rand random(sizeof(ZombiesSpawnCords)), _thenpc;
    for(new 
oo<MAX_ZOMBIESo++)
    {
        
_rand random(sizeof(ZombiesSpawnCords));
        
format(strsizeof(str), "Zombie_%d"_thenpc);
        
        
_thenpc FCNPC_Create(str);
        
FCNPC_Spawn(_thenpcrandom(311), ZombiesSpawnCords[_rand][0], ZombiesSpawnCords[_rand][1], ZombiesSpawnCords[_rand][2] + 1.0);
        
zInfo[o][zLabel] = CreateDynamic3DTextLabel(""COL_RED"Roamer Zombie\n"COL_WHITE"Health: 100", -10.00.00.220.0, .attachedplayer _thenpc, .testlos 1);
        
zInfo[o][zID] = _thenpc;
        
zInfo[o][zType] = ZOMBIE_TYPE_ROAMER
DarkMythHunter is offline   Reply With Quote
Old 16/12/2018, 01:59 PM   #6
Threshold
High-roller
 
Threshold's Avatar
 
Join Date: Nov 2012
Location: Australia
Posts: 3,088
Reputation: 519
Default Re: Invalid function or declaration

We need to see 'new zInfo[...' and the 'enum' that is used in zInfo..
__________________

Kar's Cops and Robbers 2019
Threshold is offline   Reply With Quote
Old 16/12/2018, 02:03 PM   #7
DarkMythHunter
Big Clucker
 
Join Date: May 2017
Location: Philippines
Posts: 140
Reputation: 24
Default Re: Invalid function or declaration

PHP Code:
GetZombieName(zombieid)
{
    new 
_outPut[14];

    switch(
zInfo[zombieid][zType])
    {
        case 
ZOMBIE_TYPE_ROAMER strcpy(_outPut"Roamer Zombie"sizeof(_outPut));
        case 
ZOMBIE_TYPE_BITER strcpy(_outPut"Biter Zombie"sizeof(_outPut));
        case 
ZOMBIE_TYPE_TANK strcpy(_outPut"Tank Zombie"sizeof(_outPut));
        case 
ZOMBIE_TYPE_BOSS strcpy(_outPut"Boss Zombie"sizeof(_outPut));
    }

    return 
_outPut;

I think it's this. If not, then there's nothing. I also somehow fixed the problem, since it doesn't appear in errors now. But this appears now:

Code:
Utils/Zombies.pwn(24) : warning 219: local variable "o" shadows a variable at a preceding level
Utils/Zombies.pwn(31) : error 029: invalid expression, assumed zero
Utils/Zombies.pwn(31) : warning 215: expression has no effect
Utils/Zombies.pwn(31) : error 001: expected token: ";", but found "]"
Utils/Zombies.pwn(31) : error 029: invalid expression, assumed zero
Utils/Zombies.pwn(31) : fatal error 107: too many error messages on one line
Code:
]
CreateRoamerZombies()
{
	new str[14], _rand = random(sizeof(ZombiesSpawnCords)), _thenpc;
	for(new o; o<MAX_ZOMBIES; o++)
	{
		_rand = random(sizeof(ZombiesSpawnCords));
		format(str, sizeof(str), "Zombie_%d", _thenpc);
		
		_thenpc = FCNPC_Create(str);
		FCNPC_Spawn(_thenpc, random(311), ZombiesSpawnCords[_rand][0], ZombiesSpawnCords[_rand][1], ZombiesSpawnCords[_rand][2] + 1.0);
		zInfo[o][zLabel] = CreateDynamic3DTextLabel(""COL_RED"Roamer Zombie\n"COL_WHITE"Health: 100", -1, 0.0, 0.0, 0.2, 20.0, .attachedplayer = _thenpc, .testlos = 1);
		zInfo[o][zID] = _thenpc;
		zInfo[o][zType] = ZOMBIE_TYPE_ROAMER;

The one in bold are the lines in the error. Here it is in php (used code cuz I cant use htmls)
PHP Code:
CreateRoamerZombies()
{
    new 
str[14], _rand random(sizeof(ZombiesSpawnCords)), _thenpc;
    for(new 
oo<MAX_ZOMBIESo++)
    {
        
_rand random(sizeof(ZombiesSpawnCords));
        
format(strsizeof(str), "Zombie_%d"_thenpc);
        
        
_thenpc FCNPC_Create(str);
        
FCNPC_Spawn(_thenpcrandom(311), ZombiesSpawnCords[_rand][0], ZombiesSpawnCords[_rand][1], ZombiesSpawnCords[_rand][2] + 1.0);
        
zInfo[o][zLabel] = CreateDynamic3DTextLabel(""COL_RED"Roamer Zombie\n"COL_WHITE"Health: 100", -10.00.00.220.0, .attachedplayer _thenpc, .testlos 1);
        
zInfo[o][zID] = _thenpc;
        
zInfo[o][zType] = ZOMBIE_TYPE_ROAMER
DarkMythHunter is offline   Reply With Quote
Old 17/12/2018, 09:27 AM   #8
Kaliber
Gangsta
 
Kaliber's Avatar
 
Join Date: Jun 2012
Location: Localhost
Posts: 997
Reputation: 136
Default Re: Invalid function or declaration

This shows us, just where you use it.

Not how you declared it.

We need to see the
PHP Code:
new zInfo 
Code and the defines of
PHP Code:
ITEM_ID_CIVILIAN_SKIN 
__________________
Kaliber is offline   Reply With Quote
Old 17/12/2018, 01:22 PM   #9
DarkMythHunter
Big Clucker
 
Join Date: May 2017
Location: Philippines
Posts: 140
Reputation: 24
Default Re: Invalid function or declaration

I don't see anything related about that. I don't even know myself if the script works correctly, that is why I am asking for help. I've sent the code, for you to check yourself tho.
DarkMythHunter is offline   Reply With Quote
Old 17/12/2018, 01:37 PM   #10
Kaliber
Gangsta
 
Kaliber's Avatar
 
Join Date: Jun 2012
Location: Localhost
Posts: 997
Reputation: 136
Default Re: Invalid function or declaration

We can't help you without that information.

And btw you send me nothing relevant.

As mentioned now 3 times, we need something like new zInfo

maybe its in an include..or somewhere else..it must be there..so, yeah check it out xD
__________________
Kaliber 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
Help me with this: invalid function or declaration RotAway Scripting Help 2 11/07/2015 02:57 PM
Weird error: invalid symbol name and invalid function or declaration Reboma Scripting Help 1 04/02/2014 11:58 AM
invalid function or declaration sofina PortuguÍs/Portuguese 3 23/01/2014 05:19 PM
error 010: invalid function or declaration & warning 235: public function lacks forward declaration (symbol "Drag") tboysamp Scripting Help 1 14/04/2013 06:10 AM
Need help-Invalid function or declaration lion950 Scripting Help 3 23/02/2012 06:38 PM


All times are GMT. The time now is 03:21 PM.


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