OnPlayerText
#1

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
Reply
#2

BUMP doo-diee daww
Reply
#3

It's completely dependent on what is in the filterscript. I would always suggest that you have 1 .amx file uploaded to the server so 1 gamemode and no filterscripts; but the way that you format the gamemode script is that you can use includes, for example

PHP код:
#include     "../gamemodes/inc/colours.pwn" 
Then in your gamemodes folder have a folder called inc then create a pwn file and name is colours and then in there I have the defines of all my colors, however I just save the file and don't compile then up the top of my script I have the #include and when I compile it all compile's as one .amx

That'll be an easy way to merge the two scripts together and all you'd really have to do (dependent of what is in the filterscript) is add all the callbacks that are in the filterscript under callbacks that are already in the gamemode. All the variables and defines and functions from the filterscript will then be in the gamemode just organized a bit differently.

Hope this helps.
Reply
#4

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.
Reply
#5

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.
Reply
#6

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)
Reply
#7

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.
Reply
#8

PHP код:
// Gamemode
public OnPlayerText(playeridtext[])
{
    new 
string[256];
    if(
text[0] == '#')
    {
        
format(stringsizeof(string), "[TEAM CHAT] %s | %d: %s"GetName(playerid), playeridtext[1]);
        
SendTeamMessage(GetPlayerTeam(playerid), COLOR_YELLOWstring);
        return 
0;
    }
    return 
0;
}
// Filterscripts (Work In Progress)
public OnPlayerText(playeridtext[])
{
    new 
string[256];
    
format(stringsizeof(string), "{%06x}%s | %d:"white" %s"GetPlayerColor(playerid) >>> 8GetName(playerid), playeridtext);
    
SendClientMessageToAll(-1string);
    return 
0;

Additional Notes;

The filterscript will be acting as the main system, where most of the admin commands and player commands can be found. The gamemode however will be some sort of round minigames (for example; 1.pwn is TDM, 2.pwn is Bombing & support.pwn will be the main system)
Reply
#9

So, you've managed to figure it out yourself?
Reply
#10

Put this on gamemode

PHP код:
public OnPlayerText(playeridtext[])
{
    new 
string[256], str[128];
    if(
text[0] == '#')
    {
        
format(stringsizeof(string), "[TEAM CHAT] %s | %d: %s"GetName(playerid), playeridtext[1]);
        
SendTeamMessage(GetPlayerTeam(playerid), COLOR_YELLOWstring);
        return 
1;
    }
    new 
string[256];
    
format(strsizeof(str), "{%06x}%s | %d:"white" %s"GetPlayerColor(playerid) >>> 8GetName(playerid), playeridtext);
    
SendClientMessageToAll(-1str);
    return 
0;

Delete Onplayertext on Filterscript and recomplie it

Done
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)