Include problem?
#1

Hi there I've got a problem with my GM and my include, I don't know what's wrong D:

GM part: (There is "#include <testinc>" on top of the script)

pawn Код:
forward OnGameMissionStart();
public OnGameMissionStart()
{ // Line 25 -> Then what to put in the include?
    // my code is here
}
Include part:

pawn Код:
OnGameMissionStart()
{
    // my code is here
}
Errors & warnings:

pawn Код:
C:\...mis01.pwn(25) : error 021: symbol already defined: "OnGameMissionStart"
How could I fix this?
Reply
#2

Maybe beacuse you have the same name in the include of OnGameMissioneStart callback
Reply
#3

pawn Код:
OnGameMissionStart()
{
    // my code is here
}
remove this from your gamemode becuz thats why its already defined... if its public then it has to be forwarded and for non public then not so just remove this one or the other one to fix this problem... if you remove the public one then also remove the forward
Reply
#4

That's because these both callbacks are written with the same name, just change one of them to other name.
Reply
#5

Changed the name of the script function.
Then, I just kept the function OnGameMissionStart in the include.

In both case, I got:

pawn Код:
C:\...mis01.pwn(308) : warning 203: symbol is never used: "OnGameMissionStart"
Reply
#6

This warning appears because it's not a public and it must be used like a variable, if it doesn't, a warning will appear. However, if you make it as a public, the warning will disappear;
pawn Код:
forward OnGameMissionStart();
public OnGameMissionStart()
{

    return 1;
}
Reply
#7

Okay, this warning is fixed, but now i've got several errors:

pawn Код:
C:\...testinc.inc(4) : error 017: undefined symbol "missionName"
C:\...testinc.inc(4) : warning 215: expression has no effect
C:\...testinc.inc(6) : error 017: undefined symbol "teamSkin"
C:\...testinc.inc(6) : warning 215: expression has no effect
C:\...testinc.inc(6) : error 001: expected token: ";", but found "]"
C:\...testinc.inc(6) : error 029: invalid expression, assumed zero
C:\...testinc.inc(6) : fatal error 107: too many error messages on one line
Include (testinc.inc):

pawn Код:
forward OnGameMissionStart();
public OnGameMissionStart()
{
    missionName = "Lolz"; // line 4

    teamSkin[0] = 29; // line 6
    teamSkin[1] = 280;

    teamSpawn[0][0] = 1361.3763;
    teamSpawn[0][1] = -1651.0247;
    teamSpawn[0][2] = 13.3828;
    teamSpawn[0][3] = 276.9998;

    teamSpawn[1][0] = 1580.1824;
    teamSpawn[1][1] = -1635.0011;
    teamSpawn[1][2] = 13.5612;
    teamSpawn[1][3] = 96.8315;

    teamWeapon[0][0] = 5;
    teamWeapon[0][1] = 24;
    teamWeapon[0][2] = 30;

    teamWeapon[1][0] = 3;
    teamWeapon[1][1] = 24;
    teamWeapon[1][2] = 31;

    teamWeaponAmmo[0][1] = 1;
    teamWeaponAmmo[0][2] = 250;
    teamWeaponAmmo[0][3] = 500;

    teamWeaponAmmo[1][1] = 1;
    teamWeaponAmmo[1][2] = 250;
    teamWeaponAmmo[1][2] = 500;

    return 1;
}
Pwn file:

pawn Код:
#include <testinc>

forward OnMissionInit();
public OnMissionInit()
{
    new missionName[128];
    SetGameModeText(missionName);
    new teamSkin[2];
    new Float:teamSpawn[2][4];
    new teamWeapon[2][3];
    new teamWeaponAmmo[2][3];

    AddPlayerClass(teamSkin[0], teamSpawn[0][0], teamSpawn[0][1], teamSpawn[0][2], teamSpawn[0][3], teamWeapon[0][0], teamWeaponAmmo[0][0], teamWeapon[0][1], teamWeaponAmmo[0][1], teamWeapon[0][2], teamWeaponAmmo[0][2]);
    AddPlayerClass(teamSkin[1], teamSpawn[1][0], teamSpawn[1][1], teamSpawn[1][2], teamSpawn[1][3], teamWeapon[1][0], teamWeaponAmmo[1][0], teamWeapon[1][1], teamWeaponAmmo[1][1], teamWeapon[1][2], teamWeaponAmmo[1][2]);

    return 1;
}
Reply
#8

The problem is, that it says you don't have variables with the following names: missionName, teamSkin. Anyway, will you please tell me what are you trying to do?
Reply
#9

Quote:
Originally Posted by Toreno
Посмотреть сообщение
The problem is, that it says you don't have variables with the following names: missionName, teamSkin. Anyway, will you please tell me what are you trying to do?
I understood that, but my variables are declared :/

I'm making a sort of 'mission loader' in a .pwn file, and the mission coordinates and info (weapons, skins, mission name, weapons ammo...) will be placed in the include, to be loaded into the .pwn file.

The thing is that I'm not very familiar with include files, at least with my own (never had to work with them before).
Reply
#10

I find it very useless, because it's a few variables which can be at the top of your gamemode. Anyway, in order to make it work the way you want, you should do this;

Include:
pawn Код:
new
    teamSkin[ 2 ],
    Float:teamSpawn[ 2 ][ 4 ],
    teamWeapon[ 2 ][ 3 ],
    teamWeaponAmmo[ 2 ][ 3 ]
;

OnGameMissionStart()
{
    SetGameModeText( "Lolz" );

    teamSkin[ 0 ] = 29;
    teamSkin[ 1 ] = 280;

    teamSpawn[ 0 ][ 0 ] = 1361.3763;
    teamSpawn[ 0 ][ 1 ] = -1651.0247;
    teamSpawn[ 0 ][ 2 ] = 13.3828;
    teamSpawn[ 0 ][ 3 ] = 276.9998;

    teamSpawn[ 1 ][ 0 ] = 1580.1824;
    teamSpawn[ 1 ][ 1 ] = -1635.0011;
    teamSpawn[ 1 ][ 2 ] = 13.5612;
    teamSpawn[ 1 ][ 3 ] = 96.8315;

    teamWeapon[ 0 ][ 0 ] = 5;
    teamWeapon[ 0 ][ 1 ] = 24;
    teamWeapon[ 0 ][ 2 ] = 30;

    teamWeapon[ 1 ][ 0 ] = 3;
    teamWeapon[ 1 ][ 1 ] = 24;
    teamWeapon[ 1 ][ 2 ] = 31;

    teamWeaponAmmo[ 0 ][ 0 ] = 1;
    teamWeaponAmmo[ 0 ][ 1 ] = 250;
    teamWeaponAmmo[ 0 ][ 2 ] = 500;

    teamWeaponAmmo[ 1 ][ 0 ] = 1;
    teamWeaponAmmo[ 1 ][ 1 ] = 250;
    teamWeaponAmmo[ 1 ][ 2 ] = 500;

    return 1;
}
Gamemode:
pawn Код:
public OnGameModeInit()
{
    OnGameMissionStart();

    AddPlayerClass( teamSkin[ 0 ], teamSpawn[ 0 ][ 0 ], teamSpawn[ 0 ][ 1 ], teamSpawn[ 0 ][ 2 ], teamSpawn[ 0 ][ 3 ], teamWeapon[ 0 ][ 0 ], teamWeaponAmmo[ 0 ][ 0 ], teamWeapon[ 0 ][ 1 ], teamWeaponAmmo[ 0 ][ 1 ], teamWeapon[ 0 ][ 2 ], teamWeaponAmmo[ 0 ][ 2 ] );
    AddPlayerClass( teamSkin[ 1 ], teamSpawn[ 1 ][ 0 ], teamSpawn[ 1 ][ 1 ], teamSpawn[ 1 ][ 2 ], teamSpawn[ 1 ][ 3 ], teamWeapon[ 1 ][ 0 ], teamWeaponAmmo[ 1 ][ 0 ], teamWeapon[ 1 ][ 1 ], teamWeaponAmmo[ 1 ][ 1 ], teamWeapon[ 1 ][ 2 ], teamWeaponAmmo[ 1 ][ 2 ] );

    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)