SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 09/05/2020, 12:43 PM   #1
kloning1
Huge Clucker
 
kloning1's Avatar
 
Join Date: Mar 2014
Location: Indonesia
Posts: 247
Reputation: 13
Default Modular Programming Help y_hooks

Hi, everyone, im a newbie scripting, i wanna learn to using a modular programming.
first, im learn to convert a example login register from BlueG
BlueG Example Script Cache

i got error like this
Code:
core/player/core.pwn(3) : error 010: invalid function or declaration
core/player/core.pwn(6) : error 010: invalid function or declaration
core/player/core.pwn(8) : error 021: symbol already defined: "GetPlayerName"
core/player/core.pwn(11) : error 021: symbol already defined: "mysql_format"
core/player/core.pwn(13) : error 010: invalid function or declaration
core/player/core.pwn(16) : error 010: invalid function or declaration
... and much more like invalid function or declaration
code at core/player/core.pwn
Code:
#include <YSI\y_hooks>

hook OnPlayerConnect(playerid) { // this is line 3
    g_RaceCheck[playerid]++;
    static const empty_data[E_PLAYER_DATA];
    pinfo[playerid] = empty_data; // line 6

    GetPlayerName(playerid, pinfo[playerid][pName], MAX_PLAYER_NAME); // 8

    new query[110];
    mysql_format(g_SQL, query, sizeof query, "SELECT `id`, `username`, `password`, `salt` FROM `players` WHERE `username` = '%e' LIMIT 1", pinfo[playerid][pName]); // line 11
    mysql_tquery(g_SQL, query, "OnPlayerDataCheck", "dd", playerid, g_RaceCheck[playerid]);
    return 1; // line 13
}

hook OnPlayerDisconnect(playerid, reason) { // 16
    g_RaceCheck[playerid]++;
    OnPlayerDataSave(playerid, reason);

    if(cache_is_valid(pinfo[playerid][CacheID]) {
        cache_delete(pinfo[playerid][CacheID]);
        pinfo[playerid][CacheID] = MYSQL_INVALID_CACHE;
    }
    if(pinfo[playerid][pLoginTimer]) {
        KillTimer(pinfo[playerid][pLoginTimer]);
        pinfo[playerid][pLoginTimer] = 0;
    }
    pinfo[playerid][pIsLogged] = false;
    return 1;
}
so, the question.
1. why i got a error, how to fix this error.
2. what difference if am using a \ or / on #include "core\player\core.pwn" or ... "core/player/core.pwn"
__________________



never trust anyone, except your parents, and your best friend
kloning1 is offline   Reply With Quote
Old 09/05/2020, 01:20 PM   #2
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,228
Reputation: 205
Default Re: Modular Programming Help y_hooks

1. Can you post the main file that includes core.pwn? What version of YSI?
2. https://github.com/pawn-lang/compile...File-Inclusion
__________________
Calisthenics is offline   Reply With Quote
Old 09/05/2020, 02:48 PM   #3
kloning1
Huge Clucker
 
kloning1's Avatar
 
Join Date: Mar 2014
Location: Indonesia
Posts: 247
Reputation: 13
Default Re: Modular Programming Help y_hooks

Quote:
Originally Posted by Calisthenics View Post
1. Can you post the main file that includes core.pwn? What version of YSI?
2. https://github.com/pawn-lang/compile...File-Inclusion
core/player.pwn
Code:
#include "core/player/player.pwn"
at main.pwn (gamemodes)
Code:
#include <a_samp>
#incluee <a_mysql>

#include "core/player.pwn"

main() {}
Im using YSI 5.1 without sampctl

modular
Code:
 gamemodes
main.pwn
   - core
     player.pwn
      - player
        core.pwn
I just added it to try to compile it
__________________



never trust anyone, except your parents, and your best friend
kloning1 is offline   Reply With Quote
Old 09/05/2020, 02:51 PM   #4
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,228
Reputation: 205
Default Re: Modular Programming Help y_hooks

For YSI 5:
pawn Code:
#include <YSI_Coding\y_hooks>

I use \ for path name and / for file name
pawn Code:
#include "modules\server/database.pwn"
#include "modules\server/log.pwn"
#include "modules\server/settings.pwn"
__________________
Calisthenics is offline   Reply With Quote
Old 09/05/2020, 02:57 PM   #5
kloning1
Huge Clucker
 
kloning1's Avatar
 
Join Date: Mar 2014
Location: Indonesia
Posts: 247
Reputation: 13
Default Re: Modular Programming Help y_hooks

Quote:
Originally Posted by Calisthenics View Post
For YSI 5:
pawn Code:
#include <YSI_Coding\y_hooks>

I use \ for path name and / for file name
pawn Code:
#include "modules\server/database.pwn"
#include "modules\server/log.pwn"
#include "modules\server/settings.pwn"
Where i need add this
pawn Code:
#include <YSI_Coding\y_hooks>
on a core at core\player/core.pwn or core/player.pwn
__________________



never trust anyone, except your parents, and your best friend
kloning1 is offline   Reply With Quote
Old 09/05/2020, 03:07 PM   #6
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,228
Reputation: 205
Default Re: Modular Programming Help y_hooks

Depends how you include the files, it can complain about files with same name (includes core.pwn only once and ignores other files with same name).

pawn Code:
#include "core\player/player.pwn"
Quote:
Originally Posted by kloning1 View Post
Where i need add this
pawn Code:
#include <YSI_Coding\y_hooks>
on a core at core\player/core.pwn or core/player.pwn
In the file where you use y_hooks (core\player/core.pwn)
__________________
Calisthenics 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
How to fix about complie gamemode and not responding [Modular Programming] Charisma Scripting Help 4 25/12/2019 06:30 AM
sscanf error using with modular programming memurt Scripting Help 2 24/12/2019 05:01 PM
How to have includes that depend on each other? (Modular programming) PeanutButter Scripting Help 2 07/02/2019 02:23 PM
[Tutorial] Modular Programming PatrickGTR Tutorials 32 23/01/2019 07:05 AM
[Help] Pawn IDE for modular programming Yuripe Scripting Help 4 12/09/2012 03:18 PM


All times are GMT. The time now is 08:28 PM.


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