Combining includes with publics and stocks. HELP
#1

I am making a new gamemode, and i've tried something like this:

On the top of the gamemode:
pawn Код:
#include "Server\Publics\OnVehicleSpawn.inc" // When vehicles spawn
#include "Server\Publics\OnVehicleDeath.inc" // When vehicles explodes
#include "Server\Publics\OnPlayerStateChange.inc" // When player changes his state, Ex. From FOOT to DRIVER
#include "Server\Publics\OnPlayerSpawn.inc" // When player spawns
#include "Server\Publics\OnPlayerRequestSpawn.inc" // When player is pressing the spawn button
#include "Server\Publics\OnPlayerEnterRaceCheckpoint.inc" // When player enters a race checkpoint
#include "Server\Publics\OnPlayerLeaveRaceCheckpoint.inc" // When player leaves a race checkpoint
#include "Server\Publics\OnPlayerEnterCheckpoint.inc" // When player enters a normal checkpoint
#include "Server\Publics\OnPlayerLeaveCheckpoint.inc" // When player leaves a normal checkpoint
#include "Server\Publics\OnPlayerExitVehicle.inc" // When player presses ENTER to exit a vehicle
#include "Server\Publics\OnPlayerEnterVehicle.inc" // When player presses ENTER to enter a vehicle
#include "Server\Publics\OnPlayerDeath.inc" // When player dies
#include "Server\Publics\OnObjectMoved.inc" // When object is being moved
#include "Server\Publics\OnPlayerUpdate.inc" // When player info gets updated, called every 1 second. [I think so..:/]
#include "Server\Publics\OnPlayerStreamIn.inc" // When a player streams in for other player
#include "Server\Publics\OnPlayerStreamOut.inc" // When a player streams out for other player
#include "Server\Publics\OnVehicleStreamIn.inc" // When a vehicle steams in for a player
#include "Server\Publics\OnVehicleStreamOut.inc" // When a vehicle steams out for a player
#include "Server\Publics\OnPlayerKeyStateChange.inc" // When a player clicked something
#include "Server\Publics\OnGameModeInit.inc" // When a player clicked something
#include "Server\Publics\OnGameModeExit.inc" // When a player clicked something
#include "Server\Others\MainStocks.inc" // Server main stocks
#include "Server\Others\Defines.inc" // All kind of defines
#include "Server\Others\Enums.inc" // All kind of enums
So the gamemode will be cleaner and everything, and now I made an enum called PlayerInfo.
pawn Код:
enum P_INFO
{
    pDatabaseID,
    pCash,
    pSkin
}
new PlayerInfo[ MAX_PLAYERS ][ P_INFO ];
When i'm trying to add a stock in the include MainStocks.inc for example:
pawn Код:
stock ResetPlayerVariables(playerid)
{
    PlayerInfo[ playerid ][ pCash ] = 0;
    return 1;
}
It gives me an error that PlayerInfo isn't definded.
Reply
#2

So you made an enumerator in the GAMEMODE and tried to use it in an include? Correct me if I am wrong, please!
Reply
#3

You need to include the file with the enum declaration before any files that use it.

That set up is rather bad IMO. You're still going to have files that intercept uses. You should define modules that handle a specific aspect of the mode (like accounts, spawning, etc) and hook functions/callbacks. That way each "idea" is represented separately and you can have someone else add to the gamemode with their own file, or edit only one of yours.
Reply
#4

Quote:
Originally Posted by Rajat_Pawar
Посмотреть сообщение
So you made an enumerator in the GAMEMODE and tried to use it in an include? Correct me if I am wrong, please!
Yes.
Reply
#5

Then, I guess you cannot. The enumerators, variables and all are global, however LOCAL to the script. I am not sure about anything regarding cross script variables in PAWN.
Reply
#6

Use y_master.
You can use variables between multiple scripts.
Reply
#7

Nevermind, I have fixed it.
Problem was:

This include has to be after the Enums.

#include "Server\Others\MainStocks.inc" // Server main stocks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)