SA-MP Forums Archive
strfind little help - 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: strfind little help (/showthread.php?tid=358517)



strfind little help - lewismichaelbbc - 10.07.2012

Код:
		    else if (PlayerU2B[playerid] == 2)
		    {
		        if(strfind(string, ".mp3", true))
		        {
			   		for(new i = 0; i < MAX_PLAYERS; i++)
					{
						if(IsPlayerConnected(i))
						{
		    				PlayAudioStreamForPlayer(i, inputtext);
			        	}
					}
					new sendername[128];
					GetPlayerName(playerid, sendername, sizeof(sendername));
					format(string, sizeof(string), "%s has donated to charity and has selected to play an mp3 file to all players on the server [/stopmp3 to stop the playback]", sendername);
					SendClientMessageToAll(COLOR_YELLOW, string);
				}
				else
				{
				    SendClientMessage(playerid, COLOR_YELLOW, "This Audio URL will not work. Please enter another. Make sure it has .mp3 on the end of the URL");
				    ShowPlayerDialog(playerid,U2BDIAG+1,DIALOG_STYLE_INPUT,WHOMADETHIS,"Paste the mp3 link you want to play for the whole server:","Play","Cancel");
				}
			}
This is my code. but it does not work. when i type in a link that doesnt contain mp3, the server still accepts it... how can i fix this problem?

Thanks


Re: strfind little help - MP2 - 10.07.2012

strfind returns the position of the first character of the substring in the main string (if found). It returns -1 if it doesn't find it.

Learn to read the wiki: https://sampwiki.blast.hk/wiki/Strfind