pawn Код:
/*
==================================================
|[FS]Mine by Sig Hansen and Shane Beddow |
==================================================
*/
#include <a_samp>
#define WHITE 0xFFFFFFFF
new countpos[MAX_PLAYERS];
new timer[MAX_PLAYERS];
new Text3D:laber[MAX_PLAYERS];
new mine[MAX_PLAYERS][2];
new status[MAX_PLAYERS];
new minePickup[MAX_PLAYERS];
public OnFilterScriptInit()
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext,"/mine",true)==0)
{
if (IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid, WHITE, " You're in the car, so you are prohibited from using the command!!");
return 1;
}
if(status[playerid] == 1)
{
SendClientMessage(playerid, WHITE, " You have already established a mine!");
return 1;
}
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
mine[playerid][0] = CreateObject(2992, X, Y, Z-0.85, 0.0, 0.0, 0.0);
mine[playerid][1] = CreateObject(19290, X, Y, Z-0.85, 0.0, 0.0, 0.0);
status[playerid] = 1;
countpos[playerid] = 11;
dtext(playerid);
return 1;
}
return 0;
}
forward dtext(playerid);
public dtext(playerid)
{
timer[playerid] = SetTimerEx("dtext", 1000, 0, "i", playerid);
new Float:X, Float:Y, Float:Z;
GetObjectPos(mine[playerid][0], X, Y, Z);
if(countpos[playerid] == 11)
{
laber[playerid] = Create3DTextLabel("to activate the left: \n10 seconds!",0x00F900AA,X,Y,Z+1,40.0,0);
countpos[playerid] = 10;
}
else if(countpos[playerid] == 10)
{
Update3DTextLabelText(laber[playerid], 0x64F801AA, "to activate the left: \n9 seconds!");
countpos[playerid] = 9;
}
else if(countpos[playerid] == 9)
{
Update3DTextLabelText(laber[playerid], 0xBAF801AA, "to activate the left: \n8 seconds!");
countpos[playerid] = 8;
}
else if(countpos[playerid] == 8)
{
Update3DTextLabelText(laber[playerid], 0xDAF900AA, "to activate the left: \n7 seconds!");
countpos[playerid] = 7;
}
else if(countpos[playerid] == 7)
{
Update3DTextLabelText(laber[playerid], 0xFCEB18AA, "to activate the left: \n6 seconds!");
countpos[playerid] = 6;
}
else if(countpos[playerid] == 6)
{
Update3DTextLabelText(laber[playerid], 0xFCCE18AA, "to activate the left: \n5 seconds!");
countpos[playerid] = 5;
}
else if(countpos[playerid] == 5)
{
Update3DTextLabelText(laber[playerid], 0xFBA71AAA, "to activate the left: \n4 seconds!");
countpos[playerid] = 4;
}
else if(countpos[playerid] == 4)
{
Update3DTextLabelText(laber[playerid], 0xFA6F1BAA, "to activate the left: \n3 seconds!");
countpos[playerid] = 3;
}
else if(countpos[playerid] == 3)
{
Update3DTextLabelText(laber[playerid], 0xFA421BAA, "to activate the left: \n2 seconds!");
countpos[playerid] = 2;
}
else if(countpos[playerid] == 2)
{
Update3DTextLabelText(laber[playerid], 0xFF0F0FAA, "to activate the left: \n1 second!");
countpos[playerid] = 1;
}
else if(countpos[playerid] == 1)
{
KillTimer(timer[playerid]);
Delete3DTextLabel(laber[playerid]);
countpos[playerid] = 0;
minePickup[playerid] = CreatePickup(0, 1, X, Y, Z, -1);
}
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) {continue;}
if(status[i] == 0) {continue;}
if(pickupid == minePickup[i])
{
new Float:X, Float:Y, Float:Z;
GetObjectPos(mine[i][0], X, Y, Z);
CreateExplosion(X, Y, Z, 7, 1);
DestroyPickup(minePickup[i]);
DestroyObject(mine[i][0]);
DestroyObject(mine[i][1]);
status[i] = 0;
}
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(status[playerid] == 1)
{
DestroyPickup(minePickup[playerid]);
DestroyObject(mine[playerid][0]);
DestroyObject(mine[playerid][1]);
status[playerid] = 0;
KillTimer(timer[playerid]);
Delete3DTextLabel(laber[playerid]);
}
return 1;
}
pawn Код:
//-----Mines---
forward dtext(playerid);
forward vdtext(playerid);
//------Mines--------
new countpos[MAX_PLAYERS];
new timer[MAX_PLAYERS];
new Text3D:laber[MAX_PLAYERS];
new mine[MAX_PLAYERS][2];
new status[MAX_PLAYERS];
new minePickup[MAX_PLAYERS];
new vcountpos[MAX_PLAYERS];
new vtimer[MAX_PLAYERS];
new Text3D:vlaber[MAX_PLAYERS];
new vmine[MAX_PLAYERS][2];
new vstatus[MAX_PLAYERS];
new vminePickup[MAX_PLAYERS];
public dtext(playerid)
{
timer[playerid] = SetTimerEx("dtext", 1000, 0, "i", playerid);
new Float:X, Float:Y, Float:Z;
GetObjectPos(mine[playerid][0], X, Y, Z);
if(countpos[playerid] == 11)
{
laber[playerid] = Create3DTextLabel("to activate the left: \n10 seconds!",0x00F900AA,X,Y,Z+1,40.0,0);
countpos[playerid] = 10;
}
else if(countpos[playerid] == 10)
{
Update3DTextLabelText(laber[playerid], 0x64F801AA, "to activate the left: \n9 seconds!");
countpos[playerid] = 9;
}
else if(countpos[playerid] == 9)
{
Update3DTextLabelText(laber[playerid], 0xBAF801AA, "to activate the left: \n8 seconds!");
countpos[playerid] = 8;
}
else if(countpos[playerid] == 8)
{
Update3DTextLabelText(laber[playerid], 0xDAF900AA, "to activate the left: \n7 seconds!");
countpos[playerid] = 7;
}
else if(countpos[playerid] == 7)
{
Update3DTextLabelText(laber[playerid], 0xFCEB18AA, "to activate the left: \n6 seconds!");
countpos[playerid] = 6;
}
else if(countpos[playerid] == 6)
{
Update3DTextLabelText(laber[playerid], 0xFCCE18AA, "to activate the left: \n5 seconds!");
countpos[playerid] = 5;
}
else if(countpos[playerid] == 5)
{
Update3DTextLabelText(laber[playerid], 0xFBA71AAA, "to activate the left: \n4 seconds!");
countpos[playerid] = 4;
}
else if(countpos[playerid] == 4)
{
Update3DTextLabelText(laber[playerid], 0xFA6F1BAA, "to activate the left: \n3 seconds!");
countpos[playerid] = 3;
}
else if(countpos[playerid] == 3)
{
Update3DTextLabelText(laber[playerid], 0xFA421BAA, "to activate the left: \n2 seconds!");
countpos[playerid] = 2;
}
else if(countpos[playerid] == 2)
{
Update3DTextLabelText(laber[playerid], 0xFF0F0FAA, "to activate the left: \n1 second!");
countpos[playerid] = 1;
}
else if(countpos[playerid] == 1)
{
KillTimer(timer[playerid]);
Delete3DTextLabel(laber[playerid]);
countpos[playerid] = 0;
minePickup[playerid] = CreatePickup(0, 1, X, Y, Z, -1);
}
return 1;
}
public vdtext(playerid)
{
vtimer[playerid] = SetTimerEx("vdtext", 1000, 0, "i", playerid);
new Float:X, Float:Y, Float:Z;
GetObjectPos(vmine[playerid][0], X, Y, Z);
if(vcountpos[playerid] == 11)
{
vlaber[playerid] = Create3DTextLabel("to activate the left: \n10 seconds!",0x00F900AA,X,Y,Z+1,40.0,0);
vcountpos[playerid] = 10;
}
else if(vcountpos[playerid] == 10)
{
Update3DTextLabelText(vlaber[playerid], 0x64F801AA, "to activate the left: \n9 seconds!");
vcountpos[playerid] = 9;
}
else if(vcountpos[playerid] == 9)
{
Update3DTextLabelText(vlaber[playerid], 0xBAF801AA, "to activate the left: \n8 seconds!");
vcountpos[playerid] = 8;
}
else if(vcountpos[playerid] == 8)
{
Update3DTextLabelText(vlaber[playerid], 0xDAF900AA, "to activate the left: \n7 seconds!");
vcountpos[playerid] = 7;
}
else if(vcountpos[playerid] == 7)
{
Update3DTextLabelText(vlaber[playerid], 0xFCEB18AA, "to activate the left: \n6 seconds!");
vcountpos[playerid] = 6;
}
else if(vcountpos[playerid] == 6)
{
Update3DTextLabelText(vlaber[playerid], 0xFCCE18AA, "to activate the left: \n5 seconds!");
vcountpos[playerid] = 5;
}
else if(vcountpos[playerid] == 5)
{
Update3DTextLabelText(vlaber[playerid], 0xFBA71AAA, "to activate the left: \n4 seconds!");
vcountpos[playerid] = 4;
}
else if(vcountpos[playerid] == 4)
{
Update3DTextLabelText(vlaber[playerid], 0xFA6F1BAA, "to activate the left: \n3 seconds!");
vcountpos[playerid] = 3;
}
else if(vcountpos[playerid] == 3)
{
Update3DTextLabelText(vlaber[playerid], 0xFA421BAA, "to activate the left: \n2 seconds!");
vcountpos[playerid] = 2;
}
else if(vcountpos[playerid] == 2)
{
Update3DTextLabelText(vlaber[playerid], 0xFF0F0FAA, "to activate the left: \n1 second!");
vcountpos[playerid] = 1;
}
else if(vcountpos[playerid] == 1)
{
KillTimer(vtimer[playerid]);
Delete3DTextLabel(vlaber[playerid]);
vcountpos[playerid] = 0;
vminePickup[playerid] = CreatePickup(0, 14, X, Y, Z, -1);
}
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{ for(new i=0; i<MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) {continue;}
if(status[i] == 0) {continue;}
if(pickupid == minePickup[i])
{
new Float:X, Float:Y, Float:Z;
GetObjectPos(mine[i][0], X, Y, Z);
CreateExplosion(X, Y, Z, 4, 1);
CreateExplosion(X, Y, Z, 12, 1);
DestroyPickup(minePickup[i]);
DestroyObject(mine[i][0]);
DestroyObject(mine[i][1]);
status[i] = 0;
GameTextForPlayer(playerid,"~r~You have stepped on a mine!",6000,1);
}
}
for(new i=0; i<MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) {continue;}
if(vstatus[i] == 0) {continue;}
if(pickupid == vminePickup[i])
{
new Float:X, Float:Y, Float:Z;
GetObjectPos(vmine[i][0], X, Y, Z);
CreateExplosion(X, Y, Z, 7, 1);
DestroyPickup(vminePickup[i]);
DestroyObject(vmine[i][0]);
vstatus[i] = 0;
GameTextForPlayer(playerid,"~r~You have driven over a mine!",6000,1);
}
}
return 1;
}
CMD:vmine(playerid, params[])
{
if (IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid, WHITE, " You're in the car, so you are prohibited from using the command!!");
return 1;
}
if(vstatus[playerid] == 1)
{
SendClientMessage(playerid, WHITE, " You have already established a mine!");
return 1;
}
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
vmine[playerid][0] = CreateObject(1213, X, Y, Z-0.85, 0.0, 0.0, 0.0);
vstatus[playerid] = 1;
vcountpos[playerid] = 11;
vdtext(playerid);
return 1;
}
CMD:mine(playerid, params[])
{
if (IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid, WHITE, " You're in the car, so you are prohibited from using the command!!");
return 1;
}
if(status[playerid] == 1)
{
SendClientMessage(playerid, WHITE, " You have already established a mine!");
return 1;
}
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
mine[playerid][0] = CreateObject(1213, X, Y, Z-0.85, 0.0, 0.0, 0.0);
status[playerid] = 1;
countpos[playerid] = 11;
dtext(playerid);
return 1;
}