Globals:
Код:
new gObjects[ MAX_OBJECTS ];
new TotalObjects = 0;
IsValidObjectID:
Код:
public IsValidObjectID( objectid )
{
if(
//weapons
( objectid >= 321 && objectid <= 326 )
|| ( objectid >= 330 && objectid <= 331 )
|| ( objectid >= 333 && objectid <= 339 )
|| ( objectid >= 341 && objectid <= 344 )
|| ( objectid >= 346 && objectid <= 363 )
|| ( objectid >= 365 && objectid <= 372 )
//fun stuff
|| ( objectid >= 1433 && objectid <= 13594 )
//roads
|| ( objectid >= 5482 && objectid <= 5512 )
//barriers
|| ( objectid >= 966 && objectid <= 998 )
//misc 1210-1325
|| ( objectid >= 1210 && objectid <= 1325 )
//misc 1420-1620
|| ( objectid >= 1420 && objectid <= 1620 )
//misc 1971-4522
|| ( objectid >= 1971 && objectid <= 4522 ) )
{
return 1;
}
return 0;
}
SpawnObject
Код:
public SpawnObject( playerid, modelid )
{
if( IsPlayerAdmin( playerid ) == 0 )
{
SendClientMessage( playerid, COLOR_RED, "ADMIN ONLY" );
return 0;
}
if( TotalObjects >= MAX_OBJECTS )
{
SendClientMessage( playerid, COLOR_RED, "Too many objects on the map!" );
return 0;
}
if( IsValidObjectID( modelid ) == 0 )
{
SendClientMessage( playerid, COLOR_RED, "Invalid or unsafe model id!" );
return 0;
}
new Float:SpawnRotZ;
if( IsPlayerDriver( playerid ) == 0 )
{
new Float:PlayerX, Float:PlayerY, Float:PlayerZ;
GetPlayerPos( playerid, PlayerX, PlayerY, PlayerZ );
GetPlayerFacingAngle( playerid, SpawnRotZ );
gObjects[ TotalObjects ] = CreateObject( modelid, PlayerX, PlayerY, PlayerZ, 0.0, 0.0, SpawnRotZ );
SetPlayerPos( playerid, PlayerX, PlayerY, PlayerZ + 10.0 );
}
else if( IsPlayerDriver( playerid ) == 1 )
{
new Float:CarX, Float:CarY, Float:CarZ;
GetVehiclePos( GetPlayerVehicleID( playerid ), CarX, CarY, CarZ );
GetVehicleZAngle( GetPlayerVehicleID( playerid ), SpawnRotZ );
gObjects[ TotalObjects ] = CreateObject( modelid, CarX, CarY, CarZ, 0.0, 0.0, SpawnRotZ );
SetVehiclePos( GetPlayerVehicleID( playerid ), CarX, CarY, CarZ + 10.0 );
}
TotalObjects++;
new szMsg[ 256 ];
format( szMsg, sizeof( szMsg ), "Model %i ( Object %i ) spawned by admin.", modelid, TotalObjects );
SendClientMessageToAll( COLOR_YELLOW, szMsg );
return 1;
}
DeleteSingleObject
Код:
public DeleteSingleObject( playerid, objectid )
{
if( IsPlayerAdmin( playerid ) == 0 )
{
SendClientMessage( playerid, COLOR_RED, "ADMIN ONLY" );
return 0;
}
if( IsValidObject( objectid ) == 1 )
{
DestroyObject( objectid );
new szDel[ 256 ];
format( szDel, sizeof( szDel ), "Object id %i deleted by admin!", objectid );
SendClientMessageToAll( COLOR_YELLOW, szDel );
TotalObjects--;
return 1;
}
else
{
SendClientMessage( playerid, COLOR_RED, "Invalid object id." );
return 0;
}
return 1;
}
DeleteAllObjects
Код:
public DeleteAllObjects( playerid )
{
if( IsPlayerAdmin( playerid ) == 0 )
{
SendClientMessage( playerid, COLOR_RED, "ADMIN ONLY" );
return 0;
}
for( new i = 0; i < MAX_OBJECTS; i++ )
{
if( IsValidObject( i ) == 1 )
{
DestroyObject( i );
}
}
SendClientMessageToAll( COLOR_YELLOW, "All objects deleted by admin!" );
TotalObjects = 0;
return 1;
}
SpawnRamp
Код:
public SpawnRamp( playerid, rampid )
{
new nrampid = 1655;
switch( rampid )
{
case 1:
{
nrampid = 1655;
}
case 2:
{
nrampid = 1473;
}
case 3:
{
nrampid = 1474;
}
case 4:
{
nrampid = 1475;
}
case 5:
{
nrampid = 1477;
}
default:
{
nrampid = 1655;
}
}
return SpawnObject( playerid, nrampid );
}