Onplayertext problem! -
daghost111 - 02.03.2017
Hello,i have a problem with my script.I created a mask system and it works good.The only problem is when the player is inside a vehicle.The text will send if mask is off,but when mask is on nothing happens.
CODE:
Код:
for( new i = 0; i != MAX_PLAYERS; i++ )
{
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
{
if(GetPlayerVehicleID(i) == vehicleid)
{
if(IsMask[playerid] == 1)
{
format(string, sizeof(string), "(VEHICLE) Stranger says: %s", text);
SendClientMessage(i, COLOR_FADE2, string);
}
else
{
format(string, sizeof(string), "(VEHICLE) %s says: %s", sendername, text);
SendClientMessage(i, COLOR_FADE2, string);
}
return 0;
}
}
Any idea?
Re: Onplayertext problem! -
LetsOWN[PL] - 02.03.2017
Let's try to debug your function. It is pretty simple idea: just see, if you even enter sufficient branch of code:
pawn Код:
for( new i = 0; i != MAX_PLAYERS; i++ )
{
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
{
if(GetPlayerVehicleID(i) == vehicleid)
{
if(IsMask[playerid] == 1)
{
printf("Entering the branch"); // <<<<
format(string, sizeof(string), "(VEHICLE) Stranger says: %s", text);
SendClientMessage(i, COLOR_FADE2, string);
printf("Exiting the branch"); // <<<<
}
else
{
format(string, sizeof(string), "(VEHICLE) %s says: %s", sendername, text);
SendClientMessage(i, COLOR_FADE2, string);
}
return 0;
}
}
Now, try to set the circumstances that would actually execute the code under
if(IsMask)..
Give it a try.
Re: Onplayertext problem! -
Toroi - 02.03.2017
What is that loop for, though? Is that funcion inside a command, onplayertext, or what?
Re: Onplayertext problem! -
daghost111 - 12.03.2017
Quote:
Originally Posted by LetsOWN[PL]
Let's try to debug your function. It is pretty simple idea: just see, if you even enter sufficient branch of code:
pawn Код:
for( new i = 0; i != MAX_PLAYERS; i++ ) { if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i)) { if(GetPlayerVehicleID(i) == vehicleid) { if(IsMask[playerid] == 1) { printf("Entering the branch"); // <<<< format(string, sizeof(string), "(VEHICLE) Stranger says: %s", text); SendClientMessage(i, COLOR_FADE2, string); printf("Exiting the branch"); // <<<< } else { format(string, sizeof(string), "(VEHICLE) %s says: %s", sendername, text); SendClientMessage(i, COLOR_FADE2, string);
} return 0; } }
Now, try to set the circumstances that would actually execute the code under if(IsMask)..
Give it a try.
|
I did that....when checking the logs that "Entering the branch" and "Exiting the branch" does not appear.
But the text shows in logs,but not in game.
[11:48:18] [chat] [Stranger_31221723]: a
[11:49:02] [chat] [Stranger_31221723]: Is this showing up? ---this is what shows on logs.
Re: Onplayertext problem! -
LEOTorres - 12.03.2017
Quote:
Originally Posted by daghost111
I did that....when checking the logs that "Entering the branch" and "Exiting the branch" does not appear.
|
This probably means that the variable IsMask[playerid] does not equal to one, which is the condition you have placed upon the execution of the code.
To check if this is the error, you could debug by placing
Код:
IsMask[playerid] = 1;
above your for loop, if that then works; you would place that piece of code wherever the relevant place is for the mask to be activated.
Re: Onplayertext problem! -
daghost111 - 12.03.2017
Quote:
Originally Posted by LEOTorres
This probably means that the variable IsMask[playerid] does not equal to one, which is the condition you have placed upon the execution of the code.
To check if this is the error, you could debug by placing
Код:
IsMask[playerid] = 1;
above your for loop, if that then works; you would place that piece of code wherever the relevant place is for the mask to be activated.
|
Well,i believe the IsMask[playerid] = 1; is activated good on the command mask because it works on other situtations
Example:
Код:
if(IsMask[playerid] == 1)
{
format(string, sizeof(string), "%s Stranger says: %s", accent, text);
ProxDetector(20.0, playerid,string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
SetPlayerChatBubble(playerid,text,COLOR_WHITE,20.0,5000);
return 0;
}
format(string, sizeof(string), "%s %s says: %s", accent, sendername, text);
ProxDetector(20.0, playerid,string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
SetPlayerChatBubble(playerid,text,COLOR_WHITE,20.0,5000);
This code works just fine
Re: Onplayertext problem! -
LEOTorres - 12.03.2017
Quote:
Originally Posted by daghost111
Well,i believe the IsMask[playerid] = 1; is activated good on the command mask because it works on other situtations
Example:
Код:
if(IsMask[playerid] == 1)
{
format(string, sizeof(string), "%s Stranger says: %s", accent, text);
ProxDetector(20.0, playerid,string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
SetPlayerChatBubble(playerid,text,COLOR_WHITE,20.0,5000);
return 0;
}
format(string, sizeof(string), "%s %s says: %s", accent, sendername, text);
ProxDetector(20.0, playerid,string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
SetPlayerChatBubble(playerid,text,COLOR_WHITE,20.0,5000);
This code works just fine
|
Is there a possibility you may have used a return statement earlier on in the code for the condition of the mask? As this would end the callback early, preventing the code from executing.
Could you post your entire OnPlayerText above this code, so we can determine what could be preventing this branch from executing.