switching
#1

Hi, in my server "switch mode" approximately every 12 hours, and all Command's return on 0, player's are spawning in San Fierro, off id's in Chat, when player connect, dialog don't showed and more... Where is Bug? in mode (if you think, say me where) or SA-MP?

Here screen, when it's ok
http://imageshack.us/photo/my-images/534/samp065nb.png/

and here, when is bug
http://imageshack.us/photo/my-images/842/samp064nq.png/
Reply
#2

Do you use strins, format or strcat, etc. to modify the text[] in OnPlayerText?
I had this problem and everything works fine after copying the text string into another, and then odify it with something like strins, etc.. I think the problem is getting the size of an unknown-sized string in the sizeof function of strins.

Example:
pawn Код:
public OnPlayerText(playerid,text[])
{
    new name[MAX_PLAYER_NAME],string[128];
    GetPlayerName(playerid,name,sizeof(name));
    strins(text,"[Chat]",0,sizeof(text));
    //Bugged because the server will never know the size of the string text
    format(string,sizeof(string),"%s: {FFFFFF}%s",name,text);
    SendClientMessageToAll(GetPlayerColor(playerid),string);
    return 0;
}
Change to:
pawn Код:
public OnPlayerText(playerid,text[])
{
    new name[MAX_PLAYER_NAME],string[128] = "";//You must initialize it if you use strcat
    GetPlayerName(playerid,name,sizeof(name));
    strcat(string,text);
    strins(string,"[Chat]",0,sizeof(text));
    //Works fine because the server knows the size of the string "string" this time
    format(string,sizeof(string),"%s: {FFFFFF}%s",name,string);
    SendClientMessageToAll(GetPlayerColor(playerid),string);
    return 0;
}
Or directly:
pawn Код:
public OnPlayerText(playerid,text[])
{
    new name[MAX_PLAYER_NAME],string[128];
    //You don't need to initialize it this time, GetPlayerName will do it
    GetPlayerName(playerid,string,sizeof(string));
    strcat(string,": {FFFFFF}[Chat]");
    strcat(string,text);
    SendClientMessageToAll(GetPlayerColor(playerid),string);
    return 0;
}
Reply
#3

i think, bug is not in OnPlayerText... when i use non-existent command normal return is formated... but in bug is return default ("SERVER...").. if you want, i can send you all OnPlayerText in Private Message
Reply
#4

If you did something like that in any callback(for example OnPlayerText), the whole script will be messed up that even the other callbacks and its scripts will not work. You'd better check OnPlayerText, since you modified the chat message and I had the same problem.

You can send me the callback if you don't mind.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)