When player hits spawn
#1

I was woundering if you could help me with when player spawns a dialog comes up with all the locations to spawn at with that class instead of it randomally choosing one on the server for you

Thanks
Reply
#2

You'd have to gather coordinates for each location. Under public OnPlayerSpawn callback, you would use:

https://sampwiki.blast.hk/wiki/ShowPlayerDialog

and use DIALOG_STYLE_LIST

https://sampwiki.blast.hk/wiki/Dialog_Styles
Reply
#3

How would this be added
Reply
#4

Where will i add this to
Reply
#5

Under OnPlayerSpawn callback.
Reply
#6

when you are in-game type /save to save your position then go to your my documentc then your gta san andreas and you will se folder called SAMP and you see file called savedpositions there save all your position

EDIT: like Delux13 say
Reply
#7

Код:
public OnPlayerSpawn(playerid)
{
	SetPlayerPos(playerid,0.0,0.0,3.0); //The position where the player will stand when u give him the dialog, (not important)
	ShowPlayerDialog(playerid,1,DIALOG_STYLE_LIST,"Spawns:","1. spawn 1\r\n2. spawn 2\r\n3. spawn  3","select", "cancel"); //Show the player the dialog
	return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) //What must happen when the player choose a item from the dialog
{
    switch(dialogid) // Lookup the dialogid
    {
        case 1:
        {
            if(!response)
            {
                SendClientMessage(playerid, 0xFF0000FF, "You cancelled."); //when he types cancel (copied this part from wiki IMO I would do it on a different way...)
                return 1; // We processed it
            }

            switch(listitem) // This is far more efficient than using an if-elseif-else structure
            {
                case 0: // Listitems start with 0, not 1
                {
                    SetPlayerPos(playerid,0.0,0.0,3.0);//if the player clicks teleport 1
                    return 1;
                }
                case 1:
                {
                    SetPlayerPos(playerid,0.0,0.0,3.0);//if the player clicks teleport 2
                    return 1;
                }
                case 2:
                {
                    SetPlayerPos(playerid,0.0,0.0,3.0);//if the player clicks teleport 3
                    return 1;
                }
                // Add the rest of your listitems for dialog 1 here

            }

        }
        // Add the rest of your dialogs here

    }
    return 0; // If you put return 1 here the callback will not continue to be called in other scripts (filterscripts, etc.).
}
Ok, so u just have to change the cords and add more spawn places if you want...

MOre information about the callbacks and functions:

https://sampwiki.blast.hk/wiki/OnDialogResponse
https://sampwiki.blast.hk/wiki/OnPlayerSpawn
https://sampwiki.blast.hk/wiki/SetPlayerPos
Reply
#8

Quote:
Originally Posted by knackworst
Посмотреть сообщение
Код:
public OnPlayerSpawn(playerid)
{
	SetPlayerPos(playerid,0.0,0.0,3.0); //The position where the player will stand when u give him the dialog, (not important)
	ShowPlayerDialog(playerid,1,DIALOG_STYLE_LIST,"Spawns:","1. spawn 1\r\n2. spawn 2\r\n3. spawn  3","select", "cancel"); //Show the player the dialog
	return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) //What must happen when the player choose a item from the dialog
{
    switch(dialogid) // Lookup the dialogid
    {
        case 1:
        {
            if(!response)
            {
                SendClientMessage(playerid, 0xFF0000FF, "You cancelled."); //when he types cancel (copied this part from wiki IMO I would do it on a different way...)
                return 1; // We processed it
            }

            switch(listitem) // This is far more efficient than using an if-elseif-else structure
            {
                case 0: // Listitems start with 0, not 1
                {
                    SetPlayerPos(playerid,0.0,0.0,3.0);//if the player clicks teleport 1
                    return 1;
                }
                case 1:
                {
                    SetPlayerPos(playerid,0.0,0.0,3.0);//if the player clicks teleport 2
                    return 1;
                }
                case 2:
                {
                    SetPlayerPos(playerid,0.0,0.0,3.0);//if the player clicks teleport 3
                    return 1;
                }
                // Add the rest of your listitems for dialog 1 here

            }

        }
        // Add the rest of your dialogs here

    }
    return 0; // If you put return 1 here the callback will not continue to be called in other scripts (filterscripts, etc.).
}
Ok, so u just have to change the cords and add more spawn places if you want...

MOre information about the callbacks and functions:

https://sampwiki.blast.hk/wiki/OnDialogResponse
https://sampwiki.blast.hk/wiki/OnPlayerSpawn
https://sampwiki.blast.hk/wiki/SetPlayerPos
Nice, well explained!
Reply
#9


thanks, I just feel sorry for people who are new in scripting, and having troubles with the basics, because I'm still in that problems with basic state too...(sometimes)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)