Adding Mapping to Filterscript HELP!
#1

Beware, I am a noob at scripting so anyways here is my problem:
http://gyazo.com/98dac8d7b4a7eee89a2a9a2ba276bf88

Can anyone point out on what I am doing wrong?
Reply
#2

The RemoveBuilding should be under OnPlayerConnect
Reply
#3

Quote:
Originally Posted by McBan
Посмотреть сообщение
The RemoveBuilding should be under OnPlayerConnect
That? (Excuse me for my noobiness):
http://gyazo.com/75ff48e4f61c73241342ddf860e8ac26

If it's wrong could you please give me an example?
Reply
#4

If you use CreateDynamicObject you must have Streamer By Incognito. Put objects to callback OnFilterScriptInit if it is script, to OnGameModeInit if it is gamemode. If you want remove objects, put RemoveBuildingForPlayer to callback OnPlayerConnect.
If it is filterscript.
Код:
public OnFilterScriptInit()
{
	CreateDynamicObject(...);
	return 1;
}
Or if it is gamemode.
Код:
public OnGameModeInit()
{
	CreateDynamicObject(...);
	return 1;
}
And this.
Код:
public OnPlayerConnect(playerid)
{
	RemoveBuildingForPlayer(...);
	return 1;
}
Reply
#5

Quote:
Originally Posted by Ranshand
Посмотреть сообщение
If you use CreateDynamicObject you must have Streamer By Incognito. Put objects to callback OnFilterScriptInit if it is script, to OnGameModeInit if it is gamemode. If you want remove objects, put RemoveBuildingForPlayer to callback OnPlayerConnect.
If it is filterscript.
Код:
public OnFilterScriptInit()
{
	CreateDynamicObject(...);
	return 1;
}
Or if it is gamemode.
Код:
public OnGameModeInit()
{
	CreateDynamicObject(...);
	return 1;
}
And this.
Код:
public OnPlayerConnect(playerid)
{
	RemoveBuildingForPlayer(...);
	return 1;
}
So what have I done wrong to receive these errors? (As I am a noob, I do not understand when you use the term 'callback'.
Reply
#6

To sum up a "callback" or function:

pawn Код:
public function()
{ // opener
// inside the callback
} // closer
What you basically did wrong was try to define a function that used playerid (RemoveBuildingForPlayer(playerid,) under OnFilterScriptInit, which does not have playerid defined.

This is the function for FilterScriptInit:

pawn Код:
public OnFilterScriptInit()
Playerid is defined inbetween the two brackets, that's why you put it OnPlayerConnect.

Quote:

public OnPlayerConnect(playerid)
I can't really explain it any better, but this pretty much sums it up. Also, if you are looking to do live updates (which translates to being able to update and remove mapping without restarting the server), add this to public OnFilterScriptExit().

pawn Код:
public OnFilterScriptExit()
{
    for(new i=1;i<=MAX_OBJECTS;i++)
    {
        DestroyObject(i);
    }
    return 1;
}
This loops through all existing objects and deletes them when the Filterscript exits. To call this function, go ingame, login in to RCON (/rcon login) and type /rcon reloadfs name. This will exit the script (causing all objects to dissapear) and then open the script (public OnFilterScriptInit - which basically loads all objects (if you loaded them there). RemoveBuildingForPlayer will remain unaffected however.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)