27.12.2011, 16:23
So first off, you'll need to shove them coordinates in a Float array, perhaps with an enum to keep it tidy:
And then, for the /dm command - put this in OnPlayerCommandText:
pawn Код:
// .. Enumeration for data for DM teleports.
enum DATA_DM_TPS
{
Float:X,
Float:Y,
Float:Z,
}
// .. Constant array of coordinates for teleports for /dm.
stock const Float:aDMTeles[ ][ DATA_DM_TPS ] =
{
{ 2536.0, -1603.0, 18.0 },
{ 2641.0, -1621.0, 20.0 },
{ 2611.0, -1612.0, 26.0 },
{ 2516.0, -1610.0, 22.0 },
{ 2511.0, -1620.0, 28.0 },
{ 2556.0, -1606.0, 19.0 }
};
pawn Код:
if( !strcmp(cmdtext, "/dm") )
{
//If they typed /dm, create a new random variable ranging from 0 to the
//size of the array of coordinates.
new nRand = random(sizeof aDMTeles);
//Set the player's position to one of the random entries within the array.
SetPlayerPos( playerid, aDMTeles[nRand][X], aDMTeles[nRand][Y], aDMTeles[nRand][Z] );
//Return true.
return 1;
}