What is wrong with that code? -
vent - 12.10.2011
pawn Код:
public OnPlayerText(playerid, text[])
{
if(Mobile[playerid] != 255)
{
new idx;
tmp = strtok(text, idx);
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "%s Says (cellphone): %s", sendername, text);
ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
if(IsPlayerConnected(Mobile[playerid]))
{
if(Mobile[Mobile[playerid]] == playerid)
{
SendClientMessage(Mobile[playerid], COLOR_YELLOW,string);
}
}
else
{
SendClientMessage(playerid, COLOR_YELLOW,"Theres nobody there");
}
return 0;
}
if (realchat)
{
new sendername[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid, sendername, sizeof(sendername));
sendername[strfind(sendername,"_")] = ' ';
format(string, sizeof(string), "%s says: %s", sendername, text);
ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
new lengthtime = strlen(text);
new time = lengthtime*50;
ApplyAnimation(playerid,"PED","IDLE_CHAT",4.0,0,0,0,0,time);
return 0;
}
return 1;
}
So, what's wrong with that?
The errors are:
Код:
error 017: undefined symbol "tmp" (489)
error 017: undefined symbol "strtok" (489)
error 017: undefined symbol "sendername" (490)
error 017: undefined symbol "sendername" (490)
error 029: invalid expression, assumed zero (490)
fatal error 107: too many error messages on one line (490)
pawn Код:
tmp = strtok(text, idx); //(489)
GetPlayerName(playerid, sendername, sizeof(sendername)); //(490)
Re: What is wrong with that code? -
Jafet_Macario - 12.10.2011
1.
new tmp[ 128 ];
2.
pawn Код:
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
3.
new sendername[ MAX_PLAYER_NAME ];
Re: What is wrong with that code? -
vent - 12.10.2011
pawn Код:
public OnPlayerText(playerid, text[])
{
if(Mobile[playerid] != 255)
{
new idx;
new tmp[ 128 ];
new sendername[ MAX_PLAYER_NAME ];
tmp = strtok(text, idx);
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "%s Says (cellphone): %s", sendername, text);
ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
if(IsPlayerConnected(Mobile[playerid]))
{
if(Mobile[Mobile[playerid]] == playerid)
{
SendClientMessage(Mobile[playerid], COLOR_YELLOW,string);
}
}
else
{
SendClientMessage(playerid, COLOR_YELLOW,"Theres nobody there");
}
return 0;
}
if (realchat)
{
new sendername[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid, sendername, sizeof(sendername));
sendername[strfind(sendername,"_")] = ' ';
format(string, sizeof(string), "%s says: %s", sendername, text);
ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
new lengthtime = strlen(text);
new time = lengthtime*50;
ApplyAnimation(playerid,"PED","IDLE_CHAT",4.0,0,0,0,0,time);
return 0;
}
return 1;
}
will give this:
Код:
D:\Roleplay\gamemodes\esrp.pwn(493) : error 017: undefined symbol "string"
D:\Roleplay\gamemodes\esrp.pwn(493) : error 017: undefined symbol "string"
D:\Roleplay\gamemodes\esrp.pwn(493) : error 029: invalid expression, assumed zero
D:\Roleplay\gamemodes\esrp.pwn(493) : fatal error 107: too many error messages on one line
Re: What is wrong with that code? -
Jafet_Macario - 12.10.2011
You didn't declared the string.
new string[ 128 ];
Re: What is wrong with that code? -
vent - 12.10.2011
Lol thanks, it works. (+rep for you)