Variables Help!
#5

Quote:
Originally Posted by Steven82
Посмотреть сообщение
You need to do this. I'll rewrite the code for you.

pawn Код:
new radio[MAX_PLAYERS] = 0;

if (strcmp("/radiooff", cmdtext, true, 10) == 0)
    {
        if(radio[playerid] == 1)
        {
            StopAudioStreamForPlayer(playerid);

            SendClientMessage(playerid, white, "To turn the radio back on, do /radioon");
              radio[playerid] = 0;
        }
        else if(radio[playerid] == 0)
        {
            SendClientMessage(playerid, white, "Your radio is already off!");
        }
    }

if (strcmp("/radioon", cmdtext, true, 10) == 0)
    {
        if(radio[playerid] == 0)
        {
            PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1283896");
            SendClientMessage(playerid, white, "Your radio has been turned on. To turn it off, type /radiooff");
            radio[playerid] = 1;
        }
        else if(radio[playerid] == 1)
        {
            SendClientMessage(playerid, white, "Your radio is already on, to turn it off, do /radiooff!");
        }
    }
You were making a global variable. That was your issue. Try using my code and tell me if it works or not.
Thanks alot! It worked!
Reply


Messages In This Thread
Variables Help! - by Nuke547 - 22.01.2012, 19:17
Re: Variables Help! - by HuSs3n - 22.01.2012, 19:26
Re: Variables Help! - by Steven82 - 22.01.2012, 19:29
Re: Variables Help! - by Bogdan1992 - 22.01.2012, 19:33
Re: Variables Help! - by Nuke547 - 22.01.2012, 19:36

Forum Jump:


Users browsing this thread: 1 Guest(s)