Posts: 3,715
Threads: 358
Joined: Apr 2012
Reputation:
0
So I am coding a gamemode, and there is a separated filterscript acting as the main system. The problem is, I have two OnPlayerText - from the gamemode and filterscript itself. If I return 0 to both of them then OnPlayerText's on gamemode doesn't work but OnPlayerText's filterscript work. When I return 1; on filterscript's OnPlayerText then both of OnPlayerText work except the default chat message of SA-MP is being sent first then the coded chat message.
Is there any way round to fix this otherwise I would have to move my filterscript's OnPlayerText on my gamemode's OnPlayerText
Posts: 3,715
Threads: 358
Joined: Apr 2012
Reputation:
0
So basically I can just create a similar way like for example "../gamemodes/inc/OnPlayerText.pwn" then my scripted OnPlayerText will be merged to the gamemode?
EDIT: I tried doing the technique you have mentioned but I am getting the symbol already defined errors.
Posts: 727
Threads: 111
Joined: May 2011
Reputation:
0
You shouldn't really have your callbacks in separate files, it should mainly be like admin commands, or color defines, or dialog response(since that generally gets so big) or like certain jobs.
If you're getting symbol's already defined. Depending on how it's used, for example if you have new string[128]; then you can remove one of the defines at the top of the script (of course if it isn't a local variable) If you have global variables that are named the same things but are storing different types of data re name one, weather it be the variable in the include(old filterscript) or gamemode, but if it's in the include make sure that under all the callbacks that you are renaming it to the proper variable name.
Suggestion go to where you had your filterscript in the first place and just replace the variable name that is already defined with something else.
If you're getting already defined errors with callbacks, then what you need to do is under each callback get the script from the include (old filterscript) and just place it under the callback (in the gamemodes folder).
The only thing that should be in the include file are stocks, functions, and commands, all the callbacks should be in the gamemode file.
Posts: 3,715
Threads: 358
Joined: Apr 2012
Reputation:
0
So the only way round for these callbacks which doesn't seem to work well with the gamemode is to merge them up with the gamemode?? (It is a minigames gamemode btw so I have no idea what am I doing, all I want to do is that the team chat will be scripted on the gamemode and the rest of OnPlayerText will be on FS)
Posts: 727
Threads: 111
Joined: May 2011
Reputation:
0
Show the two different OnPlayerTexts and I'll see what I can do. Remember that if the variables of the team chat are in the filterscript it will need to be merged and if the variables from the gamemode are in the filterscripts OnPlayerText it won't work either.
Posts: 727
Threads: 111
Joined: May 2011
Reputation:
0
So, you've managed to figure it out yourself?
Posts: 599
Threads: 48
Joined: May 2016
Put this on gamemode
PHP код:
public OnPlayerText(playerid, text[])
{
new string[256], str[128];
if(text[0] == '#')
{
format(string, sizeof(string), "[TEAM CHAT] %s | %d: %s", GetName(playerid), playerid, text[1]);
SendTeamMessage(GetPlayerTeam(playerid), COLOR_YELLOW, string);
return 1;
}
new string[256];
format(str, sizeof(str), "{%06x}%s | %d:"white" %s", GetPlayerColor(playerid) >>> 8, GetName(playerid), playerid, text);
SendClientMessageToAll(-1, str);
return 0;
}
Delete Onplayertext on Filterscript and recomplie it
Done