Mines code
#1

Mines Code
im trying to make a system in my script, (not a filterscript) where players can plant mines, which when stepped on by someone other than themselves detonate. I'm using the streammer plugin for the objects and the onplayerenterdynamicarea bit.
it works perfectly for playerid 0, but if anyone else plants a mine, it just blows up in their face, which isnt very good
this is what i have done
Код:
new pMines [PEEPS] = 0;
new pMinesCheckpoint [PEEPS] [3];
new pMinesObject [PEEPS] [3];

PlaceMine (playerid)
{
	new Float:x, Float:y, Float:z;
	GetPlayerPos (playerid, x, y, z);
	if (!IsValidDynamicArea(pMinesCheckpoint [playerid] [0]))
	{
		pMinesCheckpoint [playerid] [0] = CreateDynamicSphere (x, y, z-0.7, 2);
	  SendClientMessage (playerid, GREEN, "You placed a mine, don't worry, your own mines cannot hurt you!");
		pMinesObject [playerid] [0] = CreateDynamicObject (1213, x, y, z-0.7, 0, 0, 0, -1, -1, -1, 20);
	}
	else if (!IsValidDynamicArea(pMinesCheckpoint [playerid] [1]))
	{
	  pMinesCheckpoint [playerid] [1] = CreateDynamicSphere (x, y, z-0.7, 2);
	  SendClientMessage (playerid, GREEN, "You placed a mine, don't worry, your own mines cannot hurt you!");
	  pMinesObject [playerid] [1] = CreateDynamicObject (1213, x, y, z-0.7, 0, 0, 0, -1, -1, -1, 20);
	}
	else if (!IsValidDynamicArea(pMinesCheckpoint [playerid] [2]))
	{
	  pMinesCheckpoint [playerid] [2] = CreateDynamicSphere (x, y, z-0.7, 2);
	  SendClientMessage (playerid, GREEN, "You placed a mine, don't worry, your own mines cannot hurt you!");
	  pMinesObject [playerid] [2] = CreateDynamicObject (1213, x, y, z-0.7, 0, 0, 0, -1, -1, -1, 20);
	}
	else
	{
	  SendClientMessage (playerid, RED, "You already have 3 mines planted!");
	}
}

public OnPlayerEnterDynamicArea(playerid,areaid)
{
  new Float:xMine, Float:yMine, Float:zMine;
	for (new i=0; i<PEEPS; i++)
	{
	  if (IsPlayerConnected (i) && i != playerid)
	  {
	  	if (areaid == pMinesCheckpoint [i] [0])
	  	{
	      DestroyDynamicObject (pMinesObject [i] [0]);
	      GetPlayerPos (playerid, xMine, yMine, zMine);
	      CreateExplosion (xMine, yMine+0.3, zMine, 1, 5);
	      DestroyDynamicArea (pMinesCheckpoint [i] [0]);
	  	}
	  	else if (areaid == pMinesCheckpoint [i] [1])
	  	{
	  	  DestroyDynamicObject (pMinesObject [i] [1]);
	  	  GetPlayerPos (playerid, xMine, yMine, zMine);
	      CreateExplosion (xMine, yMine+0.3, zMine, 1, 5);
	  	  DestroyDynamicArea (pMinesCheckpoint [i] [1]);
	  	}
	  	else if (areaid == pMinesCheckpoint [i] [2])
	  	{
	  	  DestroyDynamicObject (pMinesObject [i] [2]);
	  	  GetPlayerPos (playerid, xMine, yMine, zMine);
	      CreateExplosion (xMine, yMine+0.3, zMine, 1, 5);
	  	  DestroyDynamicArea (pMinesCheckpoint [i] [2]);
	  	}
  	}
  	else if (IsPlayerConnected (i) && i == playerid)
  	{
  	  SendClientMessage (playerid, GREEN, "You stepped on your own mine, phew");
  	}
	}
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/placemine", cmdtext, false, 10)==0)
	{
	  if (pMines [playerid] > 0)
	  {
	  	PlaceMine (playerid);
	  	pMines [playerid] --;
	  }
	  return 1;
	}
	return 0;
}
please help me with getting this to work for everyone, thank you
Reply
#2

So if i used this how would i put it into my server? It sounds great.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)