Question regarding includes
#3

Quote:
Originally Posted by Giovanni
Посмотреть сообщение
From what I know, it does not matter how many includes you use, since they all will be later on implented in the .amx file.
Err, not necessarily no. An included directive or a header file contains necessary information which when used upon compilation time accesses the data. Yes, data conjured upon compilation is "implemented" in the amx, but this is inaccessible.

Quote:
Originally Posted by Giovanni
Does it matter at which point in my script I include an include? In my case I want to include one in the middle of the script, to make everything better organized etc.
The point of includes (as stated before) is to allow use of it's information (natives, data types etc..) in your script. They are generally appointed at the top because upon compilation, there is a sequence where each line of code is evaluated separately and individually. If includes where placed anywhere AFTER data which is relevant (data which makes use of the include) the code is simply unrecognisable.

pawn Код:
main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
}

public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

public OnPlayerConnect(playerid)
{
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
    return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
    return 1;
}

public OnRconCommand(cmd[])
{
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    return 1;
}

public OnObjectMoved(objectid)
{
    return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
    return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
    return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
    return 1;
}

public OnPlayerExitedMenu(playerid)
{
    return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
    return 1;
}

public OnPlayerUpdate(playerid)
{
    return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
    return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
    return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
    return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}

#include <a_samp>
Код:
C:\Users\Gh05t\Desktop\SA-MP\gamemodes\test.pwn(3) : error 017: undefined symbol "print"
C:\Users\Gh05t\Desktop\SA-MP\gamemodes\test.pwn(3) : warning 215: expression has no effect
C:\Users\Gh05t\Desktop\SA-MP\gamemodes\test.pwn(3) : error 001: expected token: ";", but found ")"
C:\Users\Gh05t\Desktop\SA-MP\gamemodes\test.pwn(3) : error 029: invalid expression, assumed zero
C:\Users\Gh05t\Desktop\SA-MP\gamemodes\test.pwn(3) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
In a blank gamemode, the a_samp include is most notably at the top of script. When placed at the bottom of the script (as seen in the example above) we recieve errors. According to the compiler output, "print" is undefined. This is because "print" ( the first line evaluated after main() ) is accessible only through the a_samp include. Since a_samp has not been recognized BEFORE the print the statement, an error is outputted of unrecognisable code.
Reply


Messages In This Thread
Question regarding includes - by Giovanni - 26.01.2012, 20:53
Re: Question regarding includes - by MP2 - 26.01.2012, 21:01
Re: Question regarding includes - by Gh05t_ - 26.01.2012, 23:41
AW: Question regarding includes - by Giovanni - 27.01.2012, 16:56

Forum Jump:


Users browsing this thread: 1 Guest(s)