Need help with object
#1

Im making a defuse system but the problem is, that looks like the script doesnt check if the player is near object
My code
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	new Float:x, Float:y, Float:z;
	new Float:q, Float:w, Float:e;
	new deton;
	GetObjectPos(deton, q,w,e);
	if (strcmp("/detonate", cmdtext, true, 10) == 0)
	{
		GetPlayerPos(playerid, x,y,z);
		deton = CreateObject(1252,x,y,z,0,0,0);
		GameTextForPlayer(playerid, "Bomb planted!",2000,3);
		return 1;
	}
	if (strcmp("/defuse", cmdtext, true, 10) == 0)
	{
		if(IsPlayerInRangeOfPoint(playerid, 10.5,q,w,e))
		{
		TextDrawShowForPlayer(playerid,Textdraw0[playerid]);
		TextDrawShowForPlayer(playerid,Textdraw1[playerid]);
		TextDrawShowForPlayer(playerid,Textdraw2[playerid]);
		GameTextForPlayer(playerid, "Defusing bomb!",2000,3);
		taim = SetTimer("defuse",50,true);
		playerid = defid;
		}
		else
		{
		GameTextForPlayer(playerid, "You need to be near the bomb!",2000,3);
		}
		return 1;
	}
	return 0;
}
Reply
#2

instead of placing the variables inside the
Код:
public OnPlayerCommandText(playerid, cmdtext[])
You'll have to put the variables in the local scope (at the start of the script before OnGameModeInit)

But you'll need to create an aray if you want to be able to place more bombs then one and then you'll do it like this:

if you want every player to be able to place one bomb you'll do:
Код:
new Float:PlayerBombX[MAX_PLAYERS], Float:PlayerBombY[MAX_PLAYERS], Float:PlayerBombZ[MAX_PLAYERS]; // This will create a variable where you can place your float wich you get from the function
// And of course you'll need one for each thing, x,y and z

//and here come rest of the code like 
OnGameModeInit(){//etc
}
then on the player placing bomb you do it like this
Код:
GetPlayerPos(playerid, PlayerBombX[playerid], PlayerBombY[playerid], PlayerBombZ[playerid]

//and on the defuse you'll do
IsPlayerInRangeOfPoint(playerid, 10.5,PlayerBombX[playerid], PlayerBombY[playerid], PlayerBombZ[playerid])

//and on the detonate you'll do like
CreateExplosion(PlayerBombX[playerid], PlayerBombY[playerid], PlayerBombZ[playerid]); // I don't know if that's the right function but you'll get the point i hope :)
Hope you understood something of all this mess
Reply
#3

i know how to make a limit of bombs, my problem is that when player is near the object and types /defuse it doesnt work, it looks like the player is not near the object
Reply
#4

show us line 154
Reply
#5

Dont worry now it worked i didnt defined the Float, but why it must be an array?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)