02.04.2009, 16:17
pawn Код:
new DM[MAX_PLAYERS];
new Area69[MAX_PLAYERS];
forward isPlayerInArea();
public OnGameModeInit()
{
SetTimer("isPlayerInArea",1000, true);
}
public isPlayerInArea()
{
new Float:X, Float:Y, Float:Z; //We use this to store player position
for(new playerid=0; playerid < MAX_PLAYERS; playerid++) //This line defines a name for all player, the name is "playerid"
{
if(IsPlayerConnected(playerid))
{
GetPlayerPos(playerid, X, Y, Z); //Here we are storing the player position on the variables X, Y, and Z defined previously
if (X <= 430.6979 && X >= -78.8838 && Y <= 2134.8264 && Y >= 1630.9531)
{
if (Area69[playerid] ==0)
{
Area69[playerid] = 1;
DM[playerid] = 1;
GivePlayerWeapon(playerid, 23, 400);
GivePlayerWeapon(playerid, 29, 300);
GivePlayerWeapon(playerid, 31, 150);
}
}
else
{
Area69[playerid] = 0;
DM[playerid] = 0;
}
if (DM[playerid] == 0 )
{
ResetPlayerWeapons(playerid);
new Float:Health;
new Float:Armor;
GetPlayerHealth(playerid,Health);
GetPlayerArmour(playerid, Armor);
if (Health < 100.0)
{
SetPlayerHealth(playerid,100.0);
}
if (Armor < 100.0)
{
SetPlayerArmour(playerid,100.0);
}
if ( IsPlayerInAnyVehicle(playerid) )
{
new PlayerCar;
new Float:CarHealth;
PlayerCar = GetPlayerVehicleID(playerid);
GetVehicleHealth(PlayerCar,CarHealth);
if (CarHealth < 1000.0)
{
SetVehicleHealth(PlayerCar, 1000.0);
}
}
}
}
}
}
pawn Код:
new Vehicle[MAX_PLAYERS];
new bool:VehicleSpawned[MAX_PLAYERS];
public OnPlayerConnect( playerid )
{
...
Vehicle[playerid]=INVALID_VEHICLE_ID;
...
}
public OnPlayerDisconnect( playerid, reason )
{
...
if( Vehicle[playerid] != INVALID_VEHICLE_ID )
DestroyVehicle( Vehicle[playerid] );
...
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new Float:px, Float:py, Float:pz, Float:pa;
if (strcmp("/infernus", cmdtext, true) == 0)
{
if( Vehicle[playerid] !=INVALID_VEHICLE_ID )
{
DestroyVehicle( Vehicle[playerid] );
}
VoertuigSpawned[playerid] = true;
GetPlayerFacingAngle(playerid,pa);
GetPlayerPos(playerid, px, py, pz);
Vehicle[playerid] = CreateVehicle( 411, px+5, py, pz, pa,-1, -1, 60000 );
PutPlayerInVehicle( playerid, Vehicle[playerid], 0 );
SendClientMessage(playerid, GREEN,"Spawned a Infernus!");
format(string, sizeof(string), "%s (ID %d) Has spawned a Infernus", name, playerid);
print(string);
return 1;
}
return SendClientMessage(...);
}