How can i detect.
#1

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
Reply
#2

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.
Reply
#3

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
Reply
#4

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

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

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

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

Код:
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;
Reply
#8

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

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.
Reply
#10

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.
Reply
#11

On foot
Reply
#12

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
Reply
#13

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.
Reply
#14

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
Reply
#15

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
Reply
#16

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
Reply
#17

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?
Reply
#18

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
Reply
#19

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)