SA-MP Forums Archive
Need help with command (with 1 param) /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: Need help with command (with 1 param) /radio (/showthread.php?tid=596866)



Need help with command (with 1 param) /radio - Saddin - 23.12.2015

Hello everyone, Im trying to make /radio command for example:

/radio [0-20]
I try to do like /radio 0 is turning off radio
/radio 1 is playing 1 radio station and i want to add another of course, like /radio 2, /radio 3... etc

Radio must work only in motor vehicle (not bike for example) but somehow its not working

i think its problem with those params, changing 0-20 is not good

Код:
YCMD:radio(playerid, params[], help) //Komanda za radio
{
	 #pragma unused help
	 new x_nr[128];
	 new hID;
	 hID = GetPlayerVehicleID(playerid);
	 if(IsPlayerConnected(playerid) && gPlayerLogged[playerid] == 0) return LOGINGRESKA
	 if(PlayerInfo[playerid][pSpawn] == 5) return AREAGRESKA
         if(IsBike(hID)) return BIKEGRESKARADIO
	 if(IsPlayerInVehicle(playerid, hID)) {
	 if(sscanf(params, "{u}", x_nr)) return SCM(playerid, C_KORISTENJE, "[UPUTA]: /radio [0-20]");
	 if(strcmp(x_nr, "0", true) == 0){
	 StopAudioStreamForPlayer(playerid);
	 PlayerRadio[playerid]=0;
	 new stringgh[512];
	 format(stringgh, sizeof(stringgh), "RADIO: ~w~%d", PlayerRadio[playerid]);
	 PlayerTextDrawSetString(playerid, Brzinomjer[4][playerid], stringgh);
	 }else
	 if(strcmp(x_nr, "1", true) == 0){
	 PlayAudioStreamForPlayer(playerid, "http://80.237.157.49:8070/");
	 PlayerRadio[playerid]=1;
	 new stringgh[512];
	 format(stringgh, sizeof(stringgh), "RADIO: ~w~%d", PlayerRadio[playerid]);
	 PlayerTextDrawSetString(playerid, Brzinomjer[4][playerid], stringgh);
	 }
	 }
     return 1;
}



Re: Need help with command (with 1 param) /radio - vassilis - 23.12.2015

First of all why you use strcmp when you already use sscanf?


Re: Need help with command (with 1 param) /radio - Saddin - 23.12.2015

i think i try to copy from another command to see if it is working, but now i see that too xd


Re: Need help with command (with 1 param) /radio - Ritzy2K - 23.12.2015

Quote:
Originally Posted by vassilis
Посмотреть сообщение
First of all why you use strcmp when you already use sscanf?
What?


Re: Need help with command (with 1 param) /radio - vassilis - 23.12.2015

Quote:
Originally Posted by [ND]xXZeusXx.
Посмотреть сообщение
What?
if he want to use integer he can use parameter named x_nr

if(x_nr == 1) --- radio 1
if(x_nr == 2) -- radio 2
No reason to string compare to convert the parametre from a string when you can set it as integer.
PHP код:
YCMD:radio(playeridparams[], help//Komanda za radio 

     
#pragma unused help 
     
new x_nr
     new 
hID
     
hID GetPlayerVehicleID(playerid); 
     if(
IsPlayerConnected(playerid) && gPlayerLogged[playerid] == 0) return LOGINGRESKA 
     
if(PlayerInfo[playerid][pSpawn] == 5) return AREAGRESKA
        
if(IsBike(hID)) return BIKEGRESKARADIO
     
if(IsPlayerInVehicle(playeridhID)) 
     { 
         if(
sscanf(params"d"x_nr)) return SCM(playeridC_KORISTENJE"[UPUTA]: /radio [0-20]"); 
         if(
x_nr == 0
         { 
            
StopAudioStreamForPlayer(playerid); 
            
PlayerRadio[playerid]=0
            new 
stringgh[512]; 
            
format(stringghsizeof(stringgh), "RADIO: ~w~%d"PlayerRadio[playerid]); 
            
PlayerTextDrawSetString(playeridBrzinomjer[4][playerid], stringgh); 
         } 
         else if(
x_nr == 1
         { 
                
PlayAudioStreamForPlayer(playerid"http://80.237.157.49:8070/"); 
                
PlayerRadio[playerid]=1
                new 
stringgh[512]; 
                
format(stringghsizeof(stringgh), "RADIO: ~w~%d"PlayerRadio[playerid]); 
                
PlayerTextDrawSetString(playeridBrzinomjer[4][playerid], stringgh); 
         }
     }
     return 
1

It is more simple like that i guess. Correct me if i am wrong please.
Now lets check what you ask about.