strmid(PlayerTaxiLoca[playerid], tmp, 0, strlen(text), sizeof(tmp));
format(string, sizeof string, "Redsquare Taxis says: Alright, a Taxi should be on it's way to '%s'! Thanks for calling.", PlayerTaxiLoca[playerid]);
SendClientMessage(playerid, COLOR_GREY, string);
tmp = strtok(text, idx);
If you know a better way, I'd love to hear it!
I use a command to actually get the players information, then pass it onto OnPlayerText. |
CMD:call(playerid, params[]) {
new num;
if(sscanf(params, "i", num)) return SendUsageMessage(playerid, "/call [phone number]");
else {
if(num == 454) {
PlayerInfo[playerid][pOnPhone] = true;
PlayerInfo[playerid][pCalled] = 454;
SendClientMessage(playerid, COLOR_GREY, "Redsquare Taxis says: Thank you for calling, where are you located?");
TaxiStep{playerid} = 1;
PlayerCalledTaxi{playerid} = playerid;
}
}
return 1;
}
if(TaxiStep{playerid} == 1) {
strmid(PlayerTaxiLoca[playerid], tmp, 0, strlen(text), sizeof(tmp));
format(string, sizeof string, "Redsquare Taxis says: Alright, a Taxi should be on it's way to '%s'! Thanks for calling.", PlayerTaxiLoca[playerid]);
SendClientMessage(playerid, COLOR_GREY, string);
PlayerInfo[playerid][pOnPhone] = false;
PlayerInfo[playerid][pCalled] = 0;
TaxiStep{playerid} = 0;
foreach(new i : Player) {
if(PlayerInfo[i][pTaxiDuty] == 1) {
new Float:X, Float:Y, Float:Z;
format(string, sizeof string, "Dispatch: We have a customer located at, %s.", PlayerTaxiLoca[playerid]);
SendClientMessage(i, COLOR_WHITE, string);
GetPlayerPos(playerid, X, Y, Z);
TaxiCustomerCP{i} = CreateDynamicCP(X, Y, Z, 6.0, -1, -1, i, 12000.0);
}
}
}
new originalString[] = "Hello World";
new finalString[32];
new pos = strfind(originalString, " ");
if(pos)
{
strmid(finalString, originalString, 0, pos);
}
else
{
strcat(finalString, originalString);
}
printf("Original String: '%s'\nFinal String: '%s'", originalString, finalString);
// Output:
// Original String: 'Hello World'
// Final String: 'Hello'