Код:
#include <a_samp>
#include <zcmd>
#define RED 0xE60000FF
#define ORANGE 0xF97804FF
#define WHITE 0xFFFFFFFF
#define PURPLE 0xB360FDFF
new WeaponBox;
new Text3D:BoxLabel;
new isSpawned[MAX_PLAYERS];
new bool: BoxSpawned,bool:AdminBox;
stock playername(playerid)
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName,MAX_PLAYER_NAME);
return pName;
}
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Weaponbox 4.0 © 2010 - 2011, Adam 'Hoborific' M-S loaded.");
print("--------------------------------------\n");
WeaponBox = CreateObject(3796,300,300,3000,0.00000000,0.00000000,0.00000000,100);
SetTimer("BoxSpawnCheck" , 500 ,1);
SetTimer("BoxAutoSpawn", 300 * 500 ,1);
BoxSpawned = false;
AdminBox = false;
SetTimer("RandomBoxSpawn", 300 * 1000, true);
SendClientMessageToAll(ORANGE,"Weapon Box 4.0 by Hoborific loaded");
return 1;
}
/*
forward BoxAutoSpawn();
public BoxAutoSpawn()
{
if (BoxSpawned == true)
{
DestroyObject(WeaponBox);
Delete3DTextLabel(BoxLabel);
spawnbox();
}
printf("stuff","stuff");
}
*/
forward spawnbox();
public OnFilterScriptExit()
{
print("\n--------------------------------------");
print(" Weaponbox 4.0 by Hoborific unloaded.");
print("--------------------------------------\n");
DestroyObject(WeaponBox);
Delete3DTextLabel(BoxLabel);
BoxSpawned = false;
AdminBox = false;
SendClientMessageToAll(RED,"Weapon Box 4.0 by Hoborific has been turned off.");
return 1;
}
command(box,playerid,params[]) // used to debug things mainly.
{
new Float:X, Float:Y, Float:Z;
if (IsPlayerAdmin(playerid)) {
DestroyObject(WeaponBox);
Delete3DTextLabel(BoxLabel);
GetPlayerPos(playerid,X,Y,Z);
WeaponBox = CreateObject(1550,X,Y,Z-1,0.00000000,0.00000000,0.00000000,100);
BoxLabel = Create3DTextLabel("Weapon box",ORANGE,X,Y,Z+1,100,0,true);
BoxSpawned = true;
AdminBox = true;
SendClientMessageToAll(PURPLE,"A Weapon box has been spotted in San Andreas!");
// I did plan to do more here, will do some more shit in the next update.
return 1;
}
{
SendClientMessage(playerid,RED, "You aren't an admin");
return 1;
}
}
Float:GetDistance( Float: x1, Float: y1, Float: z1, Float: x2, Float: y2, Float: z2 ) //credits to whom ever this came from, I have forgotten.
{
new Float:d;
d += floatpower(x1-x2, 2.0 );
d += floatpower(y1-y2, 2.0 );
d += floatpower(z1-z2, 2.0 );
d = floatsqroot(d);
return d;
}
public spawnbox()
{
switch (random(8))
{
case 0:{
WeaponBox = CreateObject(1550,154.3803, -1946.2564, 5.1632,100,0,0);
//BoxLabel = Create3DTextLabel("Weapon box",ORANGE,0,0,0,100,0,true);
SendClientMessageToAll(WHITE,"[GOLDPOT]: {9933FF}Find the GOldpot Worth 10000$ And 10 Scores(hint:Lighthouse)");
}
case 1:{
WeaponBox = CreateObject(1550,2100.9372, -1649.0474, 13.4390,100,0,0);
//BoxLabel = Create3DTextLabel("Weapon box",ORANGE,0,0,0,100,0,true);
SendClientMessageToAll(WHITE,"[GOLDPOT]: {9933FF}Find the GOldpot Worth 10000$ And 10 Scores(hint:CJ First Tagging Mission)");
}
case 2:{
WeaponBox = CreateObject(1550,2539.5004, 2161.4807, 10.8203,100,0,0);
//BoxLabel = Create3DTextLabel("Weapon box",ORANGE,0,0,0,100,0,true);
SendClientMessageToAll(WHITE,"[GOLDPOT]:{FF6600}Find the Goldpot Worth 10000$ And 10 Scores(hint:LV Gift And Jewellers)");
//SendClientMessageToAll(ORANGE,"{FF6600}Go get it before anyone else does!");
}
case 3:{
WeaponBox = CreateObject(1550,-1633.2149, 1421.2930, 7.1875,100,0,0);
//BoxLabel = Create3DTextLabel("Weapon box",ORANGE,0,0,0,100,0,true);
SendClientMessageToAll(WHITE,"[GOLDPOT]: {FF00CC}Find the Goldpot Worth 10000$ And 10 Scores(hint:Pier 69)");
}
case 4:{
WeaponBox = CreateObject(1550,2002.0093, 1544.3480, 13.5859,100,0,0);
//BoxLabel = Create3DTextLabel("Weapon box",ORANGE,0,0,0,100,0,true);
SendClientMessageToAll(WHITE,"[GOLDPOT]: {FFFF00}Find the Goldpot Worth 10000$ And 10 Scores(hint:PirateShip)");
}
case 5:{
WeaponBox = CreateObject(1550,2323.7473, 1283.1275, 97.5359,100,0,0);
BoxLabel = Create3DTextLabel("Weapon box",ORANGE,0,0,0,100,0,true);
SendClientMessageToAll(WHITE,"[GOLDPOT]: {FF9900}Find the Goldpot Worth 10000$ And 10 Scores(hint:On The Top of The Pyramid)");
}
case 6:{
WeaponBox = CreateObject(1550,2089.1010, 1450.8000, 10.8203,100,0,0);
//BoxLabel = Create3DTextLabel("Weapon box",ORANGE,0,0,0,100,0,true);
SendClientMessageToAll(WHITE,"[GOLDPOT]: {FF9900}Find the Goldpot Worth 10000$ And 10 Scores(hint:Royal Casino)");
}
case 7:{
WeaponBox = CreateObject(1550,-1249.8885, 501.5375, 18.2343,100,0,0);
//BoxLabel = Create3DTextLabel("Weapon box",ORANGE,0,0,0,100,0,true);
SendClientMessageToAll(WHITE,"[GOLDPOT]: {00FF00}Find the Goldpot Worth 10000$ And 10 Scores(hint:I Bet My Hydra Can Land Of That Ship)!");
}
}
return 1;
}
command(forcespawn,playerid,params)
{
if (IsPlayerAdmin(playerid))
{
BoxSpawned = true;
AdminBox = true;
spawnbox();
return 1;
}
SendClientMessage(playerid,RED,"You aren't an admin!");
return 1;
}
forward RandomBoxSpawn();
public RandomBoxSpawn()
{if (BoxSpawned == true)
{
DestroyObject(WeaponBox);
Delete3DTextLabel(BoxLabel);
spawnbox();
}
if(BoxSpawned == false)
{
BoxSpawned = true;
spawnbox();
}
}
forward BoxSpawnCheck();
public BoxSpawnCheck() //I didn't know a better way XD
{
if (AdminBox == true)
{
Weaponbox();
}
if (AdminBox == false && BoxSpawned == true)
{
Weaponbox();
return 1;
}
if (AdminBox == false && BoxSpawned == false)
{
// some function here for random box spawn
//Changed to auto random spawn function.
}
return 1;
}
forward Weaponbox();
public Weaponbox()
{
for(new i = 0; i<MAX_PLAYERS; i++) {
if(!IsPlayerConnected( i ) && isSpawned[i] ==1) continue;
new Float:X,Float:Y,Float:Z;
new Float:BX,Float:BY,Float:BZ;
GetPlayerPos(i,X,Y,Z);
GetObjectPos(WeaponBox,BX,BY,BZ);
if (GetDistance(X,Y,Z,BX,BY,BZ) <= 3.0) {
//new string[128];
// is now sen't via weapon rand format(string, 128, "[WEAPONBOX]: Found by {FF0000}%s{FFFFFF} || it contained an{FF0000} AK47!", playername(i));
//SendClientMessageToAll(WHITE,string);
DestroyObject(WeaponBox);
Delete3DTextLabel(BoxLabel);
weaponboxgive(i);
BoxSpawned = false;
AdminBox = false;
return 1;
}
}
return 1;
}
/*
if (GetDistance(X,Y,Z,BX,BY,BZ) <= 30) {
SendClientMessage(i,YELLOW," Weapon box is near!");
}
*/
forward weaponboxgive(i);
public weaponboxgive(i)
{
switch(random(7)) {
case 0:
{
new name[MAX_PLAYER_NAME], string[255];
GetPlayerName(i, name, sizeof(name));
format(string, sizeof(string), "%s has Found The GOldpot Which Worth 10000$ And 10 Scores", name);
SendClientMessageToAll(0xFFD700FF, string);
SetPlayerScore(i,GetPlayerScore(i)+10);
GivePlayerMoney(i, 10000);
}
case 1:
{
new name[MAX_PLAYER_NAME], string[255];
GetPlayerName(i, name, sizeof(name));
format(string, sizeof(string), "%s has Found The Goldpot Which Worth 10000$ And 10 Scores", name);
SendClientMessageToAll(0xFFD700FF, string);
SetPlayerScore(i,GetPlayerScore(i)+10);
GivePlayerMoney(i, 10000);
}
case 2:
{
new name[MAX_PLAYER_NAME], string[255];
GetPlayerName(i, name, sizeof(name));
format(string, sizeof(string), "%s has Found The GOldpot Which Worth 10000$ And 10 Scores", name);
SendClientMessageToAll(0xFFD700FF, string);
SetPlayerScore(i,GetPlayerScore(i)+10);
GivePlayerMoney(i, 10000);
}
case 3:
{
new name[MAX_PLAYER_NAME], string[255];
GetPlayerName(i, name, sizeof(name));
format(string, sizeof(string), "%s has Found The GOldpot Which Worth 10000$ And 10 Scores", name);
SendClientMessageToAll(0xFFD700FF, string);
SetPlayerScore(i,GetPlayerScore(i)+10);
GivePlayerMoney(i, 10000);
}
case 4:
{
new name[MAX_PLAYER_NAME], string[255];
GetPlayerName(i, name, sizeof(name));
format(string, sizeof(string), "%s has Found The GOldpot Which Worth 10000$ And 10 Scores", name);
SendClientMessageToAll(0xFFD700FF, string);
SetPlayerScore(i,GetPlayerScore(i)+10);
GivePlayerMoney(i, 10000);
}
case 5:
{
new name[MAX_PLAYER_NAME], string[255];
GetPlayerName(i, name, sizeof(name));
format(string, sizeof(string), "%s has Found The GOldpot Which Worth 10000$ And 10 Scores", name);
SendClientMessageToAll(0xFFD700FF, string);
SetPlayerScore(i,GetPlayerScore(i)+10);
GivePlayerMoney(i, 10000);
}
case 6:
{
new name[MAX_PLAYER_NAME], string[255];
GetPlayerName(i, name, sizeof(name));
format(string, sizeof(string), "%s has Found The Goldpot Which Worth 10000$ And 10 Scores", name);
SendClientMessageToAll(0xFFD700FF, string);
SetPlayerScore(i,GetPlayerScore(i)+10);
GivePlayerMoney(i, 10000);
}
}
new cash = 3500+random(4500),
string[128];
GivePlayerMoney(i, 10000);
BoxSpawned = false;
AdminBox = false;}
public OnPlayerConnect(playerid)
{
isSpawned[playerid] = false;
SetPlayerVirtualWorld(playerid,0);
return 1;
}
public OnPlayerSpawn(playerid)
{
isSpawned[playerid] = true;
return 1;
}
public OnPlayerRequestClass(playerid)
{
isSpawned[playerid] = false;
return 1;
}
command(boxadmin,playerid,params[])
{if(IsPlayerAdmin(playerid))
{
ShowPlayerDialog(playerid,42,DIALOG_STYLE_LIST,"Admin settings for the Weapon Box 4.0 by Hoborific","Enable/Disable\r\nErase Custom spawns\r\nToggle Default Spawns \r\n","Cancel","Select");
return 1;
}
SendClientMessage(playerid,RED," You are not an Rcon Administrator!");
return 1;
}
new BoxIO;
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(response)
{
switch(dialogid)
{
case 42:
{
switch(listitem)
{
case 0:
{
if (BoxIO == 1)
{
BoxIO = 0;
SendClientMessageToAll(RED,"{FF6600}[WEAPONBOX]:{FFFFFF} Weapon box 4.0 By Hoborific has been disabled!");
return 1;
}
else
{
BoxIO = 1;
SendClientMessageToAll(RED,"{00FF00}[WEAPONBOX]:{FFFFFF} Weapon box 4.0 By Hoborific has been Enabled!");
return 1;
}
}
}
}
}
}
return 1;
}