SA-MP Forums Archive
How can i detect. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How can i detect. (/showthread.php?tid=152440)



How can i detect. - NewTorran - 04.06.2010

How can i detect if the player runs up to a object added in the script?

Like if i was to add a car ( 3593 ). How would i detect when the player ran up to it and hit it?
So my question is.

How can i detect if a player runs into a script added object


Re: How can i detect. - IcyBlight - 04.06.2010

Well, you could make a timer that checks if the player is close to a car. But you can't detect if he hits it(when no one is inside).

If you should, that would require checking facing angle and keystates.... too much work imo.


Re: How can i detect. - NewTorran - 04.06.2010

Quote:
Originally Posted by IcyBlight
Well, you could make a timer that checks if the player is close to a car. But you can't detect if he hits it(when no one is inside).

If you should, that would require checking facing angle and keystates.... too much work imo.
That car was a example and the car was a object ( 3593 )
I want to detect if a player hits a object


Re: How can i detect. - IcyBlight - 04.06.2010

If you're good, maybe you can work it out from this?

http://forum.sa-mp.com/index.php?topic=164056.0


Re: How can i detect. - Aleksandar_Zivanovci - 04.06.2010

you can use function IsPlayerInRangeOfPoint(playerid,3.0, Float, Float:y, Float:z);


Re: How can i detect. - IcyBlight - 04.06.2010

Quote:
Originally Posted by Aleksandar_Zivanovci
you can use function IsPlayerInRangeOfPoint(playerid,3.0, Float, Float:y, Float:z);
He wants to detect hits.


Re: How can i detect. - Aleksandar_Zivanovci - 04.06.2010

Код:
new Object[MAX_PLAYERS];
new Float:x, Float:y, Float:z;
Object[playerid] = CreateObjec(modelid, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ);
GetObjectPos(Object[playerid], x, y, z);
for(new i=0; i<MAX_PLAYERS; i++){
if(IsPlayerInRangeOfPoint(i, 3.0, x, y, z)){
SendClientMessage(i, COLOR, "You are near some created object");
}
}
return 1;



Re: How can i detect. - Aleksandar_Zivanovci - 04.06.2010

ah, sorry for double post, my mistake (i celebrated last night and i am still little bit drunk)


Re: How can i detect. - IcyBlight - 04.06.2010

Quote:
Originally Posted by Aleksandar_Zivanovci
ah, sorry for double post, my mistake (i celebrated last night and i am still little bit drunk)
He STILL wanted to detect hits, not proximity.


Re: How can i detect. - TTJJ - 04.06.2010

Does the person need to be on foot? Or in a vehicle.

If in a vehcile. You may be able to use timers to detect if the user's vehicle has lost X or more amount of health and is in the proximity of an object then he has obviously hit it. Would be buggy if the car was shot or something like that while near an object. But I see no other way of actually detecting the collision.


Re: How can i detect. - NewTorran - 04.06.2010

On foot


Re: How can i detect. - TTJJ - 04.06.2010

Yeah you may then just have to use proximity. So if they are within 1.0 coords of the target object show them as colliding with it. I dont really think there is any way to detect the collision on foot. Sorry

Cheers, TJ


Re: How can i detect. - IcyBlight - 04.06.2010

Quote:
Originally Posted by TTJJ
Yeah you may then just have to use proximity. So if they are within 1.0 coords of the target object show them as colliding with it. I dont really think there is any way to detect the collision on foot. Sorry

Cheers, TJ
If you need to check for the player hitting the object(punching) you can check for the attack key in that proximity with the equipped weapon being "Hands"

Just a suggestion.


Re: How can i detect. - NewTorran - 04.06.2010

Thanks for your help guys but my question is still un-answered

What i want to happen is:

If a player touches a object (walks into) it will send me a message saying.. Be carefull
As my server is based on a custom made map. It is far away from San Andreas.
It is one big DM map


Re: How can i detect. - Aleksandar_Zivanovci - 04.06.2010

i have idea but still need time to realize it , it can be made in OnPlayerUpdate to check if he is near that object and then send you a message


Re: How can i detect. - NewTorran - 04.06.2010

Quote:
Originally Posted by Aleksandar_Zivanovci
i have idea but still need time to realize it , it can be made in OnPlayerUpdate to check if he is near that object and then send you a message
There is about 500/600 objects so id need it to work on all of them


Re: How can i detect. - Aleksandar_Zivanovci - 04.06.2010

Quote:
Originally Posted by Joe Torran C
Quote:
Originally Posted by Aleksandar_Zivanovci
i have idea but still need time to realize it , it can be made in OnPlayerUpdate to check if he is near that object and then send you a message
There is about 500/600 objects so id need it to work on all of them
use MySQL it will be easier, much easier

can you show me part of script where you create objects?



Re: How can i detect. - Aleksandar_Zivanovci - 04.06.2010

Quote:
Originally Posted by Seif_
For hitting, check if he's really near an object, facing it and pressed the fire key.

Quote:
Originally Posted by Joe Torran C
Quote:
Originally Posted by Aleksandar_Zivanovci
i have idea but still need time to realize it , it can be made in OnPlayerUpdate to check if he is near that object and then send you a message
There is about 500/600 objects so id need it to work on all of them
Then the answer has always been answered: you can't unless you code it for each one of them.
no your wrong


Re: How can i detect. - Aleksandar_Zivanovci - 04.06.2010

sorry for double post but see this

Код:
	format(carquery, sizeof(carquery), "SELECT * FROM static_vehicles");
	mysql_query(carquery);
	mysql_store_result();
	while(mysql_fetch_row(carrow)){
	split(carrow, carfield, '|');
	AddStaticVehicleEx(strval(carfield[0]), strval(carfield[1]), strval(carfield[2]), strval(carfield[3]), strval(carfield[4]), strval(carfield[5]), strval(carfield[6]), 600);
	}
i can create 2000 vehicles with this few lines