SA-MP Forums Archive
When player hits spawn - 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: When player hits spawn (/showthread.php?tid=273742)



When player hits spawn - Trucker[UK] - 03.08.2011

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


Re: When player hits spawn - grand.Theft.Otto - 03.08.2011

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


Re: When player hits spawn - Trucker[UK] - 03.08.2011

How would this be added


Re: When player hits spawn - Trucker[UK] - 25.08.2011

Where will i add this to


Re: When player hits spawn - [MWR]Blood - 25.08.2011

Under OnPlayerSpawn callback.


Re: When player hits spawn - doreto - 25.08.2011

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


Re: When player hits spawn - knackworst - 25.08.2011

Код:
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


Re: When player hits spawn - [MWR]Blood - 25.08.2011

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!


Re: When player hits spawn - knackworst - 25.08.2011


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)