SA-MP Forums Archive
Public function cannot be used (undefined?) - 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: Public function cannot be used (undefined?) (/showthread.php?tid=645977)



Public function cannot be used (undefined?) - Sellize - 08.12.2017

So in gamemodes/gm.pwn I have the following on line 2505

Код:
#include "../gamemodes/inc/cell_main.inc"
The file in gamemodes/inc/cell_main.inc has the follow public (and forwarded) function:

PHP код:
public OwnsCellphone(playerid) {
    return (
PlayerInfo[playerid][pPnumber] != 0);

In the gamemode, I only use this function AFTER the file has been included, and still it gives me the following error:

Код:
error 017: undefined symbol "OwnsCellphone"
(this happens for other functions from cell_main as well)


Re: Public function cannot be used (undefined?) - Sithis - 08.12.2017

If you call the function before including the file, the compiler will not know about the function yet. Try including the file in the first few lines of your script before loading anything else. See if that makes a difference.

EDIT: I should learn to read, my bad. The way you describe it, it should work. Will look into it when I have some free time.


Re: Public function cannot be used (undefined?) - 1fret - 08.12.2017

Quote:
Originally Posted by Sellize
Посмотреть сообщение
So in gamemodes/gm.pwn I have the following on line 2505

Код:
#include "../gamemodes/inc/cell_main.inc"
The file in gamemodes/inc/cell_main.inc has the follow public (and forwarded) function:

PHP код:
public OwnsCellphone(playerid) {
    return (
PlayerInfo[playerid][pPnumber] != 0);

In the gamemode, I only use this function AFTER the file has been included, and still it gives me the following error:

Код:
error 017: undefined symbol "OwnsCellphone"
(this happens for other functions from cell_main as well)
I believe includes are suppose to be in your samp folder/pawno/includes


Re: Public function cannot be used (undefined?) - Sithis - 08.12.2017

I believe 1fret is right. I've used includes from my gamemode folder once, however those had the .pwn extension and behaved exactly the same.


Re: Public function cannot be used (undefined?) - Sellize - 08.12.2017

No, you can in fact include "modular" parts of your script via the gamemodes folder. It works for like 20+ other modules in the script, just not this one.


Re: Public function cannot be used (undefined?) - Sellize - 09.12.2017

Bump. Still had no solution to this


Re: Public function cannot be used (undefined?) - OneDay - 09.12.2017

Why is it public?


Re: Public function cannot be used (undefined?) - Sellize - 09.12.2017

Quote:
Originally Posted by OneDay
Посмотреть сообщение
Why is it public?
Public so that it's globally accessible, I tried to remove the public & forwards, but it still shows the same errors


Re: Public function cannot be used (undefined?) - OneDay - 09.12.2017

public do not mean that. do you have other file also called call_main?