SA-MP Forums Archive
Use a variable in whole script - 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: Use a variable in whole script (/showthread.php?tid=629444)



Use a variable in whole script - YouHack - 26.02.2017

Hello !
Well i have this ******* to mp3 code
PHP код:
stock *******StreamForPlayer(playeridvlink[])
{
    new 
mp3link[128];
    
format(mp3link,128,"http://www.*******inmp3.com/fetch/?video=%s",vlink);
    
PlayAudioStreamForPlayersInCar(GetPlayerVehicleID(playerid),mp3link);
    return 
1;

I want the mp3link to be used in another code ( for each vehicle )
so simply when someone gets in vehicle as driver or passenger, will hear the link in mp3link variable ( that was set by the last driver ),
( it says error 017: undefined symbol "mp3link" , i hope if i can store it )
Help please :3


Re: Use a variable in whole script - iLearner - 26.02.2017

Use OnPlayerStateChange, refer wiki page for more info about it.


Re: Use a variable in whole script - YouHack - 26.02.2017

i already have the code of //PLAYER_STATE , but i need the string of mp3link to be used in whole script!!!!


Re: Use a variable in whole script - Nero_3D - 27.02.2017

just put it in global space (outside any brackets)


Re: Use a variable in whole script - YouHack - 02.03.2017

in top of script?
aand for each vehicle?


Re: Use a variable in whole script - Toroi - 02.03.2017

Yeah, all way to the top below your includes and definitions


Re: Use a variable in whole script - YouHack - 02.03.2017

what about each vehicle?


Re: Use a variable in whole script - Alkymia - 02.03.2017

Check OnPlayerStateChange callback when a player get in a car set your *******Stream... function


Re: Use a variable in whole script - JessThompson - 03.03.2017

Make a variable like

new MusicLink[MAX_VEHICLES][128];

place this at the top of your script below the includes and defines then set this when a player sets the ******* link, then within onplayerstatechange when a player enters a certin vehicle use that variable like

MusicLink[vehid];


Re: Use a variable in whole script - YouHack - 04.03.2017

Thanks that's what i was looking for