19.02.2012, 05:13
Hello fellow PAWNers,
I am here to show you how to save positions on a GMX. I will not be explaining the whole making of a registration system with y_ini, or how to load these coordinates. I will just show you how to save them..
Many experienced people will say that on SendRconCommand("GMX"), OnPlayerDisconnect is called. This is correct, but it is called after you see the opening screen(ocean view). This means your X, Y, and Z coordinates will be set to 0.
You will need y_ini(Credits to ******), zcmd(Credits to Zeex).
First, somewhere on the top you will need to do this.
All right let's get started by creating a stock function that saves your stats.
Next we have to create a GMX command.
Next we make the functions.
Okay so now, under OnPlayerDisconnect you are going to have saving stuff, so this is what you do.
Now you should be able to save positions on a GMX.
If you find any bugs, or anything wrong post here or PM.
Need help? Post here or PM me.
I am here to show you how to save positions on a GMX. I will not be explaining the whole making of a registration system with y_ini, or how to load these coordinates. I will just show you how to save them..
Many experienced people will say that on SendRconCommand("GMX"), OnPlayerDisconnect is called. This is correct, but it is called after you see the opening screen(ocean view). This means your X, Y, and Z coordinates will be set to 0.
You will need y_ini(Credits to ******), zcmd(Credits to Zeex).
First, somewhere on the top you will need to do this.
pawn Код:
new GMX[MAX_PLAYERS]
pawn Код:
stock UpdateStats(playerid)
{
new Float:PosX, Float:PosY, Float:PosZ; //Making the floats.
GetPlayerPos(playerid, PosX, PosY, PosZ); //This gets your current position, and saves them into variables.
new INI:File = INI_Open(UserPath(playerid)); //Opens the file.
INI_SetTag(File,"data");
INI_WriteFloat(File,"X",PosX); //This uses saves the X coordinate.
INI_WriteFloat(File,"Y",PosY); //This uses saves the Y coordinate.
INI_WriteFloat(File,"Z",PosZ); //This uses saves the Z coordinate.
INI_WriteInt(File,"VW",GetPlayerVirtualWorld(playerid)); //This is needed for if you disconnect in a interior, so you don't fall from the sky.
INI_WriteInt(File,"Interior",GetPlayerInterior(playerid)); // Same as above.
INI_Close(File); //Closes the file.
}
pawn Код:
cmd(gmx, playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 4) return SCM(playerid, GREY, "You are not authorized to use this command"); //Your admin information here.
SendClientMessageToAll(LIGHTRED, "GMX has been initiated by an admin, it will happen in 30 seconds."); //Sends a message to everyone telling them that a GMX will happen.
SetTimer("GMXi", 30000, false); //Setting a timer to call this function.
SetTimer("GMXl", 28000, false); //Setting a timer to call this function.
return 1;
}
pawn Код:
forward GMXl(); //You need to forward the function.
public GMXl()
{
for (new i = 0; i != MAX_PLAYERS; ++i)// This creates a loop(Can be replaced with foreach)
{
GMX[i] = 1;
UpdateStats(i);/
}
}
forward GMXi();
public GMXi()
{
SendRconCommand("GMX");
}
pawn Код:
public OnPlayerDisconnect
{
if(GMX[playerid] == 1)
{
GMX[playerid] = 0;
}
else
{
//Saving code here.
}
return 1;
}
If you find any bugs, or anything wrong post here or PM.
Need help? Post here or PM me.