why no show up?
#1

hi everyone. i have this for my police radio code:

pawn Код:
CMD:policeradio(playerid, params[]) {
    if(isnull(params))
        return SendClientMessage(playerid, COLOR_RED, "USAGE: /p(olice)r(adio) [message]");

    if(gTeam[playerid] !=Team_Police)
        return SendClientMessage(playerid, COLOR_RED, "POLICE RADIO FOR TEAM_POLICE!");

    new
        szMessage[128],
        szPlayerName[MAX_PLAYER_NAME];

    GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
    format(szMessage, sizeof(szMessage), "POLICERADIO: %s: %s", szPlayerName, params);
    for(new i = 0; i < MAX_PLAYERS; i++) {
        if(IsPlayerConnected(i) && gTeam[playerid] !=Team_Police)
            SendClientMessage(playerid, 0, szMessage);
    }
    return 1;
}
all everything works but wen i type in /policeradio , and im a cop , the message just dont show up? why?
Reply
#2

!= means fails to equal change it to ==

== means it equals that exact number no higher no lower

if(IsPlayerConnected(i) && gTeam[playerid] ==Team_Police)
Reply
#3

pawn Код:
CMD:policeradio(playerid, params[]) {
    if(isnull(params))
        return SendClientMessage(playerid, COLOR_RED, "USAGE: /p(olice)r(adio) [message]");

    if(gTeam[playerid] !=Team_Police)
        return SendClientMessage(playerid, COLOR_RED, "POLICE RADIO FOR TEAM_POLICE!");

    new
        szMessage[128],
        szPlayerName[MAX_PLAYER_NAME];

    GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
    format(szMessage, sizeof(szMessage), "POLICERADIO: %s: %s", szPlayerName, params);
    for(new i = 0; i < MAX_PLAYERS; i++) {
        if(IsPlayerConnected(i) && gTeam[playerid] ==Team_Police)// you were sending it to people who were NOT Team_Police
            SendClientMessage(playerid, 0, szMessage);
    }
    return 1;
}
As stated in the comment, you were sending the message to people who were NOT Team_Police.
Reply
#4

Thanks for copying exactly what I put above
Reply
#5

Meh, you beat me to it. :P
Reply
#6

no that dont work. it now only work for civilian and other players and wen civilian and other players type /policeradio [message] it doesnt show.
Reply
#7

pawn Код:
CMD:policeradio(playerid, params[]) {
    if(isnull(params))
        return SendClientMessage(playerid, COLOR_RED, "USAGE: /p(olice)r(adio) [message]");

    if(gTeam[playerid] !=Team_Police)
        return SendClientMessage(playerid, COLOR_RED, "POLICE RADIO FOR TEAM_POLICE!");

    new
        szMessage[128],
        szPlayerName[MAX_PLAYER_NAME];

    GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
    format(szMessage, sizeof(szMessage), "POLICERADIO: %s: %s", szPlayerName, params);
    for(new i = 0; i < MAX_PLAYERS; i++) {
        if(IsPlayerConnected(i) && gTeam[i] ==Team_Police)
            SendClientMessage(i, 0, szMessage);
    }
    return 1;
}
You were checking if playerid was Team_Police (and sending the message only to playerid). I assume that you want to send it to all cops, so you needed to use i in gTeam[i] and SendClientMessage(i,0,szMessage)
Reply
#8

Quote:
Originally Posted by Yuryfury
Посмотреть сообщение
pawn Код:
CMD:policeradio(playerid, params[]) {
    if(isnull(params))
        return SendClientMessage(playerid, COLOR_RED, "USAGE: /p(olice)r(adio) [message]");

    if(gTeam[playerid] !=Team_Police)
        return SendClientMessage(playerid, COLOR_RED, "POLICE RADIO FOR TEAM_POLICE!");

    new
        szMessage[128],
        szPlayerName[MAX_PLAYER_NAME];

    GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
    format(szMessage, sizeof(szMessage), "POLICERADIO: %s: %s", szPlayerName, params);
    for(new i = 0; i < MAX_PLAYERS; i++) {
        if(IsPlayerConnected(i) && gTeam[i] ==Team_Police)
            SendClientMessage(i, 0, szMessage);
    }
    return 1;
}
You were checking if playerid was Team_Police (and sending the message only to playerid). I assume that you want to send it to all cops, so you needed to use i in gTeam[i] and SendClientMessage(i,0,szMessage)
hi sir!!! u are so very smart! thanks you so much!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)