SA-MP Forums Archive
Problem with radio - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem with radio (/showthread.php?tid=541057)



Problem with radio - bnnb8 - 09.10.2014

Hello, I wanna to do radio system for cops, there's no have any errors.
that's my code:
PHP код:
if(strcmp("/r",cmdtext,true) == 0)
{
new 
text[256];
if(
dini_Int(FFile(playerid),"Cop") == 0) return SendClientMessage(playerid,0xFFFFFFFF,"{0b84ff}Error:{ffffff} Sorry, but the command does not exist. {0b84ff}/help {ffffff}or {0b84ff}/helpme{ffffff} if needed.");
{
    for(new 
0MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i))
        {
if(
dini_Int(FFile(i),"Cop") == 1){
            
text strrest(cmdtextidx);
            if(!
strlen(text)) return SendClientMessage(playerid0xFFFFFF00"USAGE: /r [TEXT]");
                
format(string256"{ffec8b}** [Police] Officer %s: %s **"GetName(playerid), text);
                return 
SendClientMessage(i0x006BFFFFstring);
    }
}
}
}

but in the server it's doesn't work what may I do?


Re: Problem with radio - Rudy_ - 09.10.2014

EDIT: Try this one, again edite
Try this
pawn Код:
if(strcmp("/r",cmdtext,true) == 0)
{
    new text[256];
    if(dini_Int(FFile(playerid),"Cop") == 0) return SendClientMessage(playerid,0xFFFFFFFF,"{0b84ff}Error:{ffffff}     Sorry, but the command does not exist. {0b84ff}/help {ffffff}or {0b84ff}/helpme{ffffff} if needed.");
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                if(dini_Int(FFile(i),"Cop") == 1){
                text = strrest(cmdtext, idx);
                if(!strlen(text)) return SendClientMessage(playerid, 0xFFFFFF00, "USAGE: /r [TEXT]");
                format(string, 256, "{ffec8b}** [Police] Officer %s: %s **", GetName(playerid), text);
               return SendClientMessage(i, 0x006BFFFF, string);
            }
        }
    }
    return 1;
}
or this

pawn Код:
if(strcmp("/r",cmdtext,true) == 0)
{
    new text[256];
    if(dini_Int(FFile(playerid),"Cop") == 0) return SendClientMessage(playerid,0xFFFFFFFF,"{0b84ff}Error:{ffffff}     Sorry, but the command does not exist. {0b84ff}/help {ffffff}or {0b84ff}/helpme{ffffff} if needed.");
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                if(dini_Int(FFile(i),"Cop") == 1){
                text = strrest(cmdtext, idx);
                if(!strlen(text)) return SendClientMessage(playerid, 0xFFFFFF00, "USAGE: /r [TEXT]");
                format(string, 256, "{ffec8b}** [Police] Officer %s: %s **", GetName(playerid), text);
                return SendClientMessage(i, 0x006BFFFF, string);
            }
        }
    }
    return 1;
}



Re: Problem with radio - bnnb8 - 09.10.2014

Quote:
Originally Posted by Rudy_
Посмотреть сообщение
EDIT: Try this one, again edite
Try this
pawn Код:
if(strcmp("/r",cmdtext,true) == 0)
{
    new text[256];
    if(dini_Int(FFile(playerid),"Cop") == 0) return SendClientMessage(playerid,0xFFFFFFFF,"{0b84ff}Error:{ffffff}     Sorry, but the command does not exist. {0b84ff}/help {ffffff}or {0b84ff}/helpme{ffffff} if needed.");
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                if(dini_Int(FFile(i),"Cop") == 1){
                text = strrest(cmdtext, idx);
                if(!strlen(text)) return SendClientMessage(playerid, 0xFFFFFF00, "USAGE: /r [TEXT]");
                format(string, 256, "{ffec8b}** [Police] Officer %s: %s **", GetName(playerid), text);
               return SendClientMessage(i, 0x006BFFFF, string);
            }
        }
    }
    return 1;
}
or this

pawn Код:
if(strcmp("/r",cmdtext,true) == 0)
{
    new text[256];
    if(dini_Int(FFile(playerid),"Cop") == 0) return SendClientMessage(playerid,0xFFFFFFFF,"{0b84ff}Error:{ffffff}     Sorry, but the command does not exist. {0b84ff}/help {ffffff}or {0b84ff}/helpme{ffffff} if needed.");
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                if(dini_Int(FFile(i),"Cop") == 1){
                text = strrest(cmdtext, idx);
                if(!strlen(text)) return SendClientMessage(playerid, 0xFFFFFF00, "USAGE: /r [TEXT]");
                format(string, 256, "{ffec8b}** [Police] Officer %s: %s **", GetName(playerid), text);
                return SendClientMessage(i, 0x006BFFFF, string);
            }
        }
    }
    return 1;
}
Still!


Re: Problem with radio - bnnb8 - 13.10.2014

Bump


Re: Problem with radio - bnnb8 - 07.11.2014

Bump


Re: Problem with radio - bnnb8 - 13.11.2014

Bump, anyone please?


Re: Problem with radio - Banana_Ghost - 13.11.2014

try this.
Also, I would recommend using ycmd, foreach, and sscanf instead of default functions (they are way faster).
pawn Код:
if(strcmp("/r",cmdtext,true, 2) == 0)
{
    new text[128],string[128];
    if(dini_Int(FFile(playerid),"Cop") == 0) return SendClientMessage(playerid,0xFFFFFFFF,"{0b84ff}Error:{ffffff}     Sorry, but the command does not exist. {0b84ff}/help {ffffff}or {0b84ff}/helpme{ffffff} if needed.");'
    if(!strlen(text)) return SendClientMessage(playerid, 0xFFFFFF00, "USAGE: /r [TEXT]");
    else
    {
        for(new i; i<MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                if(dini_Int(FFile(i),"Cop") == 1)
                {
                    text = strrest(cmdtext, idx);
                    format(string, sizeof(string), "{ffec8b}** [Police] Officer %s: %s **", GetName(playerid), text);
                    return SendClientMessage(i, 0x006BFFFF, string);
                }
            }
        }
    }
    return 1;
}