[Help] Radio system, no response
#1

Hello guys, well I have the problem when I do /r Text it says "Unknown Message". When I try just /r It says "Radio: :" Help me please.

CODE: http://pastebin.com/HPvpHj6q
Reply
#2

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.
Reply
#3

I am not using GF. It's being made from new one. Totally fresh.
Reply
#4

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
Reply
#5

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.
Reply
#6

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.
Reply
#7

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"
Reply
#8

Put this at the top of OnPlayerCommandText:

pawn Код:
new cmd[128], idx;
    cmd = strtok(cmdtext, idx);
Reply
#9

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.
Reply
#10

Bump
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)