27.12.2011, 17:10
Put the enum and aDMTeles outside of a callback. Like this:
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 }
};
public OnPlayerCommandText(playerid, cmdtext[])
{
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;
}
}