SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 30/06/2017, 05:56 AM   #1
SteSte
Huge Clucker
 
SteSte's Avatar
 
Join Date: Aug 2015
Location: United States
Posts: 187
Reputation: 19
Default How to add music to your login/register system

Introducing a SteSte Tutorial...
Have you ever forgotten your password for a slight moment and you just couldn't seem to remember it? or have you ever tried to register to a server and you just can't think of a password? Well greetings everyone, today I'm gonna teach you how to add music to your login/register system, so when your trying to come up with your password you have smooth music playing in your background, after all, studies show listening to music while thinking helps you process more information so you should remember your password in seconds and after this tutorial it should be easy for you to add music to your scripts - trust me!



First, make sure your script compiles successfully, because I'm thinking you already have a login/register system.

If your able to create a login/register system then I'm guessing you already have a good knowledge in pawn, so I want you to scroll down to OnPlayerConnect.

PHP Code:
public OnPlayerConnect(playerid)
{
    
    return 
1;

Your OnPlayerConnect should already have codes in there so I want you to
write
PHP Code:
PlayAudioStreamForPlayer(playerid"your music link"); 
for "your music link", I'm gonna add my own music.

Right now your code should look like this.
PHP Code:
public OnPlayerConnect(playerid)
{
    
PlayAudioStreamForPlayer(playerid"http://k003.kiwi6.com/hotlink/f2huimquyv/Underdog_Rap.mp3");
    return 
1;

PlayAudioStreamForPlayer means exactly what its name says.

Now music should be playing in the background if you compile and go test, but it will never stop, so I want you to go down to OnPlayerSpawn and write StopAudioStreamForPlayer(playerid);

PHP Code:
public OnPlayerSpawn(playerid)
{
    
StopAudioStreamForPlayer(playerid);
    return 
1;

What this code does is it stops the current music audio when the player spawns. And that's it, you should have a complete login/register system.

But what if you want to add more than one music to play randomly
first scroll up to the top of your script and add a new variable like this...

PHP Code:
new ConnectionMusic[][] =
{

}; 
I named my variable ConnectionMusic, but you can name yours anything you like, inside that variable code write the list of music links you want.

PHP Code:
new ConnectionMusic[][] =

    
"http://k003.kiwi6.com/hotlink/f2huimquyv/Underdog_Rap.mp3",
    
"http://k003.kiwi6.com/hotlink/c5pnr0fezv/Twerk_it_like_Miley.mp3",
    
"http://k003.kiwi6.com/hotlink/5vxfd34f49/Super_Hero_Music_-_Action_Suspense.mp3",
    
"http://k003.kiwi6.com/hotlink/qp7vhh9fjb/Kodak_Tunnel_Vision.mp3"
}; 
Make sure its written like this "link" inside the brackets,
now as you can see I listed 4 music links, now go down to your OnPlayConnect.

Change..
PHP Code:
public OnPlayerConnect(playerid)
{
    
PlayAudioStreamForPlayer(playerid"http://k003.kiwi6.com/hotlink/f2huimquyv/Underdog_Rap.mp3");
    return 
1;

To..
PHP Code:
PlayAudioStreamForPlayer(playeridConnectionMusic[random(sizeof(ConnectionMusic))]); 
instead of the music link we just add the variable name ConnectionMusic
and since its being randomly picked I added random and also the size. Now that concludes the tutorial, connect and as your players login, music would be playing in the background and it should help them remember their passwords



Things to consider
Youtube music won't work, so I suggest you convert them to .mp3,
because it needs to be an instant link or it won't play.

to convert to mp3 just search up youtube to mp3 converter and
you'll see a lot of converter's you can choose from, and for linking
I suggest you use Kiwi6.com, its free and easy to use
and for privacy select public, to be able to link it.


I circled in red the mp3 link made from kiwi6.com

Feel free to comment and thank you for reading.
__________________
Working On:
Superhuman - Roleplay
PM me if your interested in helping.

Last edited by SteSte; 17/07/2017 at 11:35 PM.
SteSte is offline   Reply With Quote
Old 30/06/2017, 06:32 AM   #2
Beryllium
Big Clucker
 
Join Date: May 2017
Location: Egypt.
Posts: 67
Reputation: 4
Default Re: How to add music to your login/register system

Simple and Easy, No need for tutorial, But will be helpful for newbies. Anyway, Good job.

EDIT:

Why should they add this? They're not recommended to add them.

PHP Code:
// INCLUDES 
#include <a_samp> 
#include <zcmd> 
#include <sscanf2> 
#include <foreach> 
#include <streamer> 
#include <YSI\y_ini> 

// DEFINES 
#define Col_Grey 0xD2D2D2D2 
#define Col_Red 0xAA3333AA 
#define Col_Green 0x33AA33AA 
#define Dialog_Log 1 
#define Dialog_Reg 2 
#define User_Path "/Users/%s.ini" 
Also,

Edit this:

PHP Code:

new ConnectionMusic[][] = 
{
"http://k003.kiwi6.com/hotlink/f2huimquyv/Underdog_Rap.mp3"
"http://k003.kiwi6.com/hotlink/c5pnr0fezv/Twerk_it_like_Miley.mp3"
"http://k003.kiwi6.com/hotlink/5vxfd34f49/Super_Hero_Music_-_Action_Suspense.mp3"
"http://k003.kiwi6.com/hotlink/qp7vhh9fjb/Kodak_Tunnel_Vision.mp3"
}; 
Instead of:

PHP Code:
new ConnectionMusic[][] = 
{
"http://k003.kiwi6.com/hotlink/f2huimquyv/Underdog_Rap.mp3"
"http://k003.kiwi6.com/hotlink/c5pnr0fezv/Twerk_it_like_Miley.mp3"
"http://k003.kiwi6.com/hotlink/5vxfd34f49/Super_Hero_Music_-_Action_Suspense.mp3"
"http://k003.kiwi6.com/hotlink/qp7vhh9fjb/Kodak_Tunnel_Vision.mp3"}; 
It may cause a problem (not sure of this, didn't scripted for a while)

Last edited by Beryllium; 30/06/2017 at 06:40 AM. Reason: adding more things.
Beryllium is offline   Reply With Quote
Old 30/06/2017, 06:46 AM   #3
SteSte
Huge Clucker
 
SteSte's Avatar
 
Join Date: Aug 2015
Location: United States
Posts: 187
Reputation: 19
Default Re: How to add music to your login/register system

Quote:
Originally Posted by Beryllium View Post
Simple and Easy, No need for tutorial, But will be helpful for newbies. Anyway, Good job.
Thank you.

The { } thing doesn't cause problems, it compiles nicely.
__________________
Working On:
Superhuman - Roleplay
PM me if your interested in helping.
SteSte is offline   Reply With Quote
Old 30/06/2017, 06:48 AM   #4
Beryllium
Big Clucker
 
Join Date: May 2017
Location: Egypt.
Posts: 67
Reputation: 4
Default Re: How to add music to your login/register system

Quote:
Originally Posted by Heroleo911003 View Post
The { } thing doesn't cause problems, it compiles nicely.
Alright, Good.

But just correct them because it may cause a problems while the users replacing their custom songs.
Beryllium is offline   Reply With Quote
Old 30/06/2017, 06:52 AM   #5
SteSte
Huge Clucker
 
SteSte's Avatar
 
Join Date: Aug 2015
Location: United States
Posts: 187
Reputation: 19
Default Re: How to add music to your login/register system

Quote:
Originally Posted by Beryllium View Post
Alright, Good.

But just correct them because it may cause a problems while the users replacing their custom songs.
Okay sure, I'll change it, I've already fixed the defines part
__________________
Working On:
Superhuman - Roleplay
PM me if your interested in helping.
SteSte is offline   Reply With Quote
Old 30/06/2017, 06:07 PM   #6
Sunehildeep
High-roller
 
Sunehildeep's Avatar
 
Join Date: Mar 2016
Posts: 1,002
Reputation: 89
Default Re: How to add music to your login/register system

Nice tutorial
__________________
Sunehildeep is offline   Reply With Quote
Old 30/06/2017, 10:53 PM   #7
SteSte
Huge Clucker
 
SteSte's Avatar
 
Join Date: Aug 2015
Location: United States
Posts: 187
Reputation: 19
Default Re: How to add music to your login/register system

Quote:
Originally Posted by Sunehildeep View Post
Nice tutorial
Thanks.
__________________
Working On:
Superhuman - Roleplay
PM me if your interested in helping.
SteSte is offline   Reply With Quote
Old 30/06/2017, 11:24 PM   #8
Astralis
High-roller
 
Join Date: Sep 2009
Location: France
Posts: 3,108
Reputation: 388
Default Re: How to add music to your login/register system

I like the part where it would play a random song instead of one, good tutorial for newbies.
__________________
http://samp4you.com
Hosted Tab 25/mo || 100 Slots 5,50/mo
Astralis is online now   Reply With Quote
Old 01/07/2017, 12:05 AM   #9
Hansrutger
Gangsta
 
Hansrutger's Avatar
 
Join Date: May 2011
Location: Sweden
Posts: 946
Reputation: 158
Default Re: How to add music to your login/register system

Quote:
Originally Posted by Beryllium View Post
But just correct them because it may cause a problems while the users replacing their custom songs.
Lulwut. Very good objective argumentation of why the brackets should be placed in your favor.

Interesting tutorial, good job.
__________________


Hansrutger is offline   Reply With Quote
Old 01/07/2017, 04:20 PM   #10
SteSte
Huge Clucker
 
SteSte's Avatar
 
Join Date: Aug 2015
Location: United States
Posts: 187
Reputation: 19
Default Re: How to add music to your login/register system

Thank you all!
__________________
Working On:
Superhuman - Roleplay
PM me if your interested in helping.
SteSte is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] Register & Login system (verification code + return password + auto login [by ip]) benel1 Filterscripts 20 26/11/2014 10:05 PM
the best login/register system without admin system and show in dialog misho1 Help Archive 2 06/05/2011 01:24 AM


All times are GMT. The time now is 11:58 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.