31.01.2010, 04:16
Hey all,
I need help with the conversion of a command to use under OnPlayerText. The point of this function is to replace the need for the use of /c to talk over a cellphone when a player is on a call. Below I've posted the original code, and the code I've formatted for use under OnPlayerText.
Original:
Modified:
I also get these few errors upon compiling.
These errors are all corresponding to this part of the code. I've recognised the error regarding 'cmdtext' referring to the line:
.. and would anybody be able to suggest, looking at my code, what I can replace to make this work?
Cheers.
I need help with the conversion of a command to use under OnPlayerText. The point of this function is to replace the need for the use of /c to talk over a cellphone when a player is on a call. Below I've posted the original code, and the code I've formatted for use under OnPlayerText.
Original:
pawn Код:
else if((strcmp(cmd, "/cell", true) == 0) || (strcmp(cmd, "/c", true) == 0))
{
if(PlayerHasItem(playerid, ITEM_PHONE) == INVALID_ITEM_SLOT) {
SendClientMessage(playerid, COLOR_LIGHTRED, "ERROR: You need to buy a phone first.");
return 1;
}
if(gCalling[playerid][CELL_CALLTYPE] != 0) // player or system call
{
if(strcount(cmdtext, ' ') < 2)
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /cell [message]");
return 1;
}
idx++; // remove the space
strmid(string, cmdtext, idx, sizeof(string));
new text[255];
//new pn[24];
//new pn = GetUserName(playerid);
format(text, sizeof(text), "%s (cellphone): %s", GetUserName(playerid), string);
SendLocalMessage(20.0, playerid, text, COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
new targetid = gCalling[playerid][CELL_PLAYERID];
if(gCalling[playerid][CELL_CALLTYPE] == 1) //player call
{
if(!IsPlayerConnected(targetid))
{
SendClientMessage(playerid, COLOR_LIGHTRED, "* Line goes dead.");
StopCall(playerid);
return 1;
}
format(text, sizeof(text), "%s (cellphone): %s", GetUserName(playerid), string);
SendLocalMessage(20.0, playerid, text, COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
}
else
{
//non player number
SystemCall(playerid, targetid, string);
format(text, sizeof(text), "%s (cellphone): %s", GetUserName(targetid), string);
SendClientMessage(playerid, COLOR_WHITE, text);
return 1;
}
format(text, sizeof(text), "%s (cellphone): %s", GetUserName(targetid), string);
SendClientMessage(playerid, COLOR_WHITE, text);
if (IsPlayerInAnyVehicle(playerid)) SendFBIVanMessage(playerid, COLOR_FBI1,COLOR_FBI2,COLOR_FBI3,COLOR_FBI4,COLOR_FBI5, string, 40.0);
else SendFBIVanMessage(playerid, COLOR_FBI1,COLOR_FBI2,COLOR_FBI3,COLOR_FBI4,COLOR_FBI5, string, 60.0);
if (PlayerInfo[playerid][pWired] == 1) format(text,sizeof(text),"[WIRE][Cell] %s says: %s",PlayerInfo[playerid][pName],string), SendFBIMessage(NICESKY, text);
}
else
{
SendClientMessage(playerid, COLOR_LIGHTRED, "ERROR: You do not have a call.");
}
return 1;
}
pawn Код:
if(gCalling[playerid][CELL_CALLTYPE] != 0) // player or system call
{
idx++; // remove the space
strmid(string, cmdtext, idx, sizeof(string));
new text[255];
//new pn[24];
//new pn = GetUserName(playerid);
format(text, sizeof(text), "%s (cellphone): %s", GetUserName(playerid), string);
SendLocalMessage(20.0, playerid, text, COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
new targetid = gCalling[playerid][CELL_PLAYERID];
if(gCalling[playerid][CELL_CALLTYPE] == 1) //player call
{
if(!IsPlayerConnected(targetid))
{
SendClientMessage(playerid, COLOR_LIGHTRED, "* Line goes dead.");
StopCall(playerid);
return 1;
}
format(text, sizeof(text), "%s (cellphone): %s", GetUserName(playerid), string);
SendLocalMessage(20.0, playerid, text, COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
}
else
{
//non player number
SystemCall(playerid, targetid, string);
format(text, sizeof(text), "%s (cellphone): %s", GetUserName(targetid), string);
SendClientMessage(playerid, COLOR_WHITE, text);
return 1;
}
format(text, sizeof(text), "%s (cellphone): %s", GetUserName(targetid), string);
SendClientMessage(playerid, COLOR_WHITE, text);
if (IsPlayerInAnyVehicle(playerid)) SendFBIVanMessage(playerid, COLOR_FBI1,COLOR_FBI2,COLOR_FBI3,COLOR_FBI4,COLOR_FBI5, string, 40.0);
else SendFBIVanMessage(playerid, COLOR_FBI1,COLOR_FBI2,COLOR_FBI3,COLOR_FBI4,COLOR_FBI5, string, 60.0);
if (PlayerInfo[playerid][pWired] == 1) format(text,sizeof(text),"[WIRE][Cell] %s says: %s",PlayerInfo[playerid][pName],string), SendFBIMessage(NICESKY, text);
}
return 1;
}
Код:
C:\Documents and Settings\Admin\Desktop\SA-MP\GameMode\Aria v2 31-1-10 Final.pwn(3914) : warning 225: unreachable code C:\Documents and Settings\Admin\Desktop\SA-MP\GameMode\Aria v2 31-1-10 Final.pwn(3916) : error 017: undefined symbol "idx" C:\Documents and Settings\Admin\Desktop\SA-MP\GameMode\Aria v2 31-1-10 Final.pwn(3916) : warning 215: expression has no effect C:\Documents and Settings\Admin\Desktop\SA-MP\GameMode\Aria v2 31-1-10 Final.pwn(3917) : error 017: undefined symbol "cmdtext" C:\Documents and Settings\Admin\Desktop\SA-MP\GameMode\Aria v2 31-1-10 Final.pwn(3917) : error 035: argument type mismatch (argument 2) C:\Documents and Settings\Admin\Desktop\SA-MP\GameMode\Aria v2 31-1-10 Final.pwn(3919) : warning 219: local variable "text" shadows a variable at a preceding level
pawn Код:
strmid(string, cmdtext, idx, sizeof(string));
Cheers.