Spawn Script
#1

Hey guys!

I was wondering how i do a script for a diolog box to come up and to say some locations and when you press it it takes you there!

Please help, i promised myself i would open the server tonight.

Thanks JamesJ899
Reply
#2

https://sampwiki.blast.hk/wiki/How_to_Create_a_Dialog
https://sampwiki.blast.hk/wiki/SetSpawnInfo
https://sampwiki.blast.hk/wiki/SpawnPlayer
Reply
#3

Using ZCMD... (you can get zcmd by clicking this link)

pawn Код:
#include <zcmd>

#define ColorRed 0xFF0000FF

CMD:teleport(playerid,params[])
{
    SendClientMessage(playerid,ColorRed,"So you would like to teleport, please select one of our various locations!");
    ShowPlayerDialog(playerid,1,DIALOG_STYLE_LIST,"Teleports","Los Santos\r\nSan Fierro\r\nLas Venturas","Teleport", "Nevermind.");
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1)
    {
        case 1:
        {
            if(!response)
            {
                SendClientMessage(playerid,ColorRed,"You cancelled.");
                return 1;
            }

            switch(listitem)
            {
                case 0:
                {
                    SetPlayerPos(playerid,X,Y,Z);
                    SetPlayerFacingAngle(playerid,A)
                    SendClientMessage(playerid,ColorRed,"You have teleported to Los Santos!")
                    new pname[24],message[128];
                    GetPlayerName(playerid,pname,24);
                    format(message, sizeof(message),"[Teleport]: %s has teleported to Los Santos!",playername);
                    SendClientMessageToAll(playerid,ColorRed,message)
                }
                case 1:
                {
                    SetPlayerPos(playerid,X,Y,Z);
                    SetPlayerFacingAngle(playerid,A)
                    SendClientMessage(playerid,ColorRed,"You have teleported to San Fierro!")
                    new pname[24],message[128];
                    GetPlayerName(playerid,pname,24);
                    format(message, sizeof(message),"[Teleport]: %s has teleported to San Fierro!",playername);
                    SendClientMessageToAll(playerid,ColorRed,message)
                }
                case 2:
                {
                    SetPlayerPos(playerid,X,Y,Z);
                    SetPlayerFacingAngle(playerid,A)
                    SendClientMessage(playerid,ColorRed,"You have teleported to Las Venturas!")
                    new pname[24],message[128];
                    GetPlayerName(playerid,pname,24);
                    format(message, sizeof(message),"[Teleport]: %s has teleported to Las Venturas!",playername);
                    SendClientMessageToAll(playerid,ColorRed,message)
                }
            }
        }
    }
    return 0;
}
Now an explaination...

We have to
pawn Код:
#include <zcmd>
// This is what I used for the command, its how I create commands on my server!
Then I used the color red but I dont want to have to put 0xFF0000FF so instead I define it at the top.
pawn Код:
#define ColorRed 0xFF0000FF
For more colors create them HERE and place them between the 0x...FF .

Now under your publics or if you find where you commands, place the
pawn Код:
CMD:teleport(playerid,params[])
{
    SendClientMessage(playerid,ColorRed,"So you would like to teleport, please select one of our various locations!"); //sends a message so he/she knows what to do.
    ShowPlayerDialog(playerid,1,DIALOG_STYLE_LIST,"Teleports","Los Santos\r\nSan Fierro\r\nLas Venturas","Teleport", "Nevermind."); //show the player the dialogbox
}
under them.

Now after we have that settled we must make our actual dialog box.
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1) //this gets the dialog box id.
    {
        case 1:
        {
            if(!response) // if player hits nevermind.
            {
                SendClientMessage(playerid,ColorRed,"You cancelled.");
                return 1;
            }

            switch(listitem) // this is important
            {
                case 0: //our first item Los Santos
                {
                    SetPlayerPos(playerid,X,Y,Z); // the x y z location that the player ports to
                    SetPlayerFacingAngle(playerid,A) // where do you want him to be facing?
                    SendClientMessage(playerid,ColorRed,"You have teleported to Los Santos!") // sends a client message to the player that he successfully teleported.
                    new pname[24],message[128];
                    GetPlayerName(playerid,pname,24);
                    format(message, sizeof(message),"[Teleport]: %s has teleported to Los Santos!",playername);
                    SendClientMessageToAll(playerid,ColorRed,message) // it will send a message to all players that he teleported.
                }
                case 1: // the second option San Fierro
                {
                    SetPlayerPos(playerid,X,Y,Z);
                    SetPlayerFacingAngle(playerid,A)
                    SendClientMessage(playerid,ColorRed,"You have teleported to San Fierro!")
                    new pname[24],message[128];
                    GetPlayerName(playerid,pname,24);
                    format(message, sizeof(message),"[Teleport]: %s has teleported to San Fierro!",playername);
                    SendClientMessageToAll(playerid,ColorRed,message)
                }
                case 2: // the third option Las Venturas
                {
                    SetPlayerPos(playerid,X,Y,Z);
                    SetPlayerFacingAngle(playerid,A)
                    SendClientMessage(playerid,ColorRed,"You have teleported to Las Venturas!")
                    new pname[24],message[128];
                    GetPlayerName(playerid,pname,24);
                    format(message, sizeof(message),"[Teleport]: %s has teleported to Las Venturas!",playername);
                    SendClientMessageToAll(playerid,ColorRed,message)
                }
            }
        }
    }
    return 0; // return 0...
}
And this ofcourse you can make room for in the Public OnDialogResponse callback!

Resources:
wiki.sa-mp.com
https://sampwiki.blast.hk/wiki/SendClientMessage
https://sampwiki.blast.hk/wiki/SendClientMessageToAll
https://sampwiki.blast.hk/wiki/ShowPlayerDialog
https://sampwiki.blast.hk/wiki/OnDialogResponse
And many tutorial LOCATED HERE.
Reply
#4

Thank you so much very clear and would you know by any chance about vehicle! I want loads of vehicles to spawn were the players do but i want them to spawn again if they take one, if that makes sence?! Thanks 10/10
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)