Posts: 6,129
Threads: 36
Joined: Jan 2009
As I stated in the other thread (but it's not the cause of your problem - it's just worth acknowledging):
Quote:
The length parameter is optional, there's not really any need for it, and even so that's completely wrong, '/r' is not 10 characters, and you've missed a quotation mark.
|
The problems are that you don't get the players name - you need to use GetPlayerName() and unload the name in to the 'pName' variable (if it exists) and that you create a string - but you store no values in it - Pawn is not magical, you need to give it some instructions.
pawn Код:
if(strcmp(cmdtext, "/r", true) == 0) {
if(GetPlayerTeam(playerid) == TEAM_POLICE) {
tmp = strtok(cmdtext, idx);
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
format(string, sizeof(string), "* Radio: %s: %s", pName, tmp);
SendPoliceMessage(COLOR_LIGHTBLUE, string);
return 1;
}
return 1;
}
Since you have 'pName' I presume you're using a Godfather (edit), so you'll probably have strtok and 'tmp' defined, so this should work.
Posts: 255
Threads: 57
Joined: Jun 2011
Reputation:
0
I am not using GF. It's being made from new one. Totally fresh.
Posts: 255
Threads: 57
Joined: Jun 2011
Reputation:
0
C:\Users\Maki\Desktop\TDM\gamemodes\TDM.pwn(350) : error 017: undefined symbol "tmp"
C:\Users\Maki\Desktop\TDM\gamemodes\TDM.pwn(350) : error 017: undefined symbol "strtok"
C:\Users\Maki\Desktop\TDM\gamemodes\TDM.pwn(354) : error 017: undefined symbol "string"
C:\Users\Maki\Desktop\TDM\gamemodes\TDM.pwn(354) : error 017: undefined symbol "string"
C:\Users\Maki\Desktop\TDM\gamemodes\TDM.pwn(354) : error 029: invalid expression, assumed zero
C:\Users\Maki\Desktop\TDM\gamemodes\TDM.pwn(354) : fatal error 107: too many error messages on one line
Posts: 359
Threads: 63
Joined: Jul 2010
Reputation:
0
if your making a new GameMode I really suggest and hope you use sscanf and some derivative of zcmd/dcmd
Dini is fine for file format of normal systems and low player bases but for large players and huge player files I would recommend Y_Ini (yes or mysql)
It's my belief that a lot more people around these forums know and will help with Sscanf/Zcmd I even personally don't touch strtok and strcmp issues.
EDIT: This is purely opinion, don't jump my ass over this, I am not looking to start a war or derail the OP's thread.
Posts: 6,129
Threads: 36
Joined: Jan 2009
Oops, I accidentally deleted the new string.
pawn Код:
if(strcmp(cmdtext, "/r", true) == 0) {
if(GetPlayerTeam(playerid) == TEAM_POLICE) {
new string[128];
tmp = strtok(cmdtext, idx);
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
format(string, sizeof(string), "* Radio: %s: %s", pName, tmp);
SendPoliceMessage(COLOR_LIGHTBLUE, string);
return 1;
}
return 1;
}
Get strtok from here:
https://sampwiki.blast.hk/wiki/Strtok
But you should highly consider your options - zcmd with sscanf would be a wiser choice to develop your gamemode with, strtok and plain commands through OnPlayerCommandText are untidy, messy and hard to maintain.
Posts: 255
Threads: 57
Joined: Jun 2011
Reputation:
0
C:\Users\Maki\Desktop\TDM\gamemodes\TDM.pwn(380) : error 017: undefined symbol "tmp"
C:\Users\Maki\Desktop\TDM\gamemodes\TDM.pwn(380) : error 017: undefined symbol "idx"
C:\Users\Maki\Desktop\TDM\gamemodes\TDM.pwn(383) : error 017: undefined symbol "idx"
Posts: 6,129
Threads: 36
Joined: Jan 2009
Put this at the top of OnPlayerCommandText:
pawn Код:
new cmd[128], idx;
cmd = strtok(cmdtext, idx);
Posts: 255
Threads: 57
Joined: Jun 2011
Reputation:
0
new cmd[128], idx;
cmd = strtok(cmdtext, idx);
new tmp[256];
tmp = strtok(cmdtext, idx);
new string[128];
tmp = strtok(cmdtext, idx);
Compiled, run it.
/r "Radio: Toro_Acasta:
Output not displaying.