set spawn
#7

You can use this as a reference to make your own spawn set code. Your spawn system would be easier to do with a registration system; then you can use something like:

We define DCMD:

pawn Код:
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
In OnPlayerCommandText:

pawn Код:
dcmd(spawn, 5, cmdtext);
We create our command (Out of publics):

pawn Код:
dcmd_spawn(playerid,params[]) // We create the command and we save the position of the player.
{
#pragma unused params
new Float: X, Float: Y, Float:Z, Interior;
GetPlayerPos(playerid, X, Y, Z); Interior = GetPlayerInterior(playerid);
dUserSetINT(Player(playerid)).("X", floatround(X));
dUserSetINT(Player(playerid)).("Y", floatround(Y));
dUserSetINT(Player(playerid)).("Z", floatround(Z));
dUserSetINT(Player(playerid)).("Interior", Interior);
dUserSetINT(Player(playerid)).("World", (GetPlayerVirtualWorld(playerid)));
return SendClientMessage(playerid, 0xFFA600AA, "Spawn point saved!");
}
We put our code in OnPlayerSpawn to spawn the player in the position:

pawn Код:
public OnPlayerSpawn(playerid) // Spawning code.
{
#pragma unused params
if(dUserINT(Player(playerid)).("X")!=0)
{
Pos(playerid);
SetPlayerVirtualWorld(playerid, (dUserINT(Player(playerid)).("World")) );
return SendClientMessage(playerid, 0xFFA600AA, "Spawned succesfully!");
}
else return SendClientMessage(playerid, 0xFF0000AA, "You must save a spawn position first.");
}
Create a public for "Pos":

pawn Код:
forward Pos(playerid);
// We set the position of the player.
public Pos(playerid)
{
if(dUserINT(Player(playerid)).("X")!=0)
{
SetPlayerPos(playerid, float(dUserINT(Player(playerid)).("X")), float(dUserINT(Player(playerid)).("Y")), float(dUserINT(Player(playerid)).("Z")));
SetPlayerInterior(playerid, (dUserINT(Player(playerid)).("Interior")));
}
}
Note: This is just a reference for you because we do not know if you are going to use a registration system or what kind of registration system you are using. I made this using my own registration system. It is possible to make a spawn set without a registration system but it is more complicated.

Good luck
Reply


Messages In This Thread
set spawn - by Spartaaaaa - 09.08.2014, 22:47
Re: set spawn - by Stinged - 09.08.2014, 23:05
Re: set spawn - by Spartaaaaa - 10.08.2014, 00:52
Re: set spawn - by Spartaaaaa - 10.08.2014, 02:01
Re: set spawn - by Spartaaaaa - 10.08.2014, 04:10
Re: set spawn - by Spartaaaaa - 10.08.2014, 17:52
Answer - by Ygzeb - 10.08.2014, 18:57

Forum Jump:


Users browsing this thread: 1 Guest(s)