pickup an object
#1

how to pickup an object? i have a createplayerobject and i want when i enter in him, destroy him. how i can do this?
Reply
#2

make a timer that loops:
PHP код:
SetTimer("OneSLoop"10001); 
check for player position near the object:
PHP код:
forward OneSLoop();
public 
OneSLoop(){
    for(new 
iMAX_PLAYERSi++){
        if(
IsPlayerInRangeOfPoint(i2.0xyz){
            
DestroyPlayerObject(iObject[i]);
            
SendClientMessage(playerid, -1"You have collected the object! :D");
        }
    }

Reply
#3

Quote:
Originally Posted by Vennox
Посмотреть сообщение
make a timer that loops:
PHP код:
SetTimer("OneSLoop"10001); 
check for player position near the object:
PHP код:
forward OneSLoop();
public 
OneSLoop(){
    for(new 
iMAX_PLAYERSi++){
        if(
IsPlayerInRangeOfPoint(i2.0xyz){
            
DestroyPlayerObject(iObject[i]);
            
SendClientMessage(playerid, -1"You have collected the object! :D");
        }
    }

The timer sucks in such cases and would cause much problems, Why not create a small dynamic area around the object and when the player enter it, destroy the object and give it to the player via attachment, or you can make a large dynamic area and loop through all the players inside it to see who is near / in the same place of the object..

You can use
PHP код:
 CreateDynamicCircle(Float:xFloat:yFloat:sizeworldid = -1interiorid = -1playerid = -1
and
PHP код:
 IsPlayerInDynamicArea(playeridareaidrecheck 0
to check if he got into it or no..

Then add your normal code which is
PHP код:
for(new iMAX_PLAYERSi++){
        if(
IsPlayerInRangeOfPoint(i2.0xyz){
            
DestroyPlayerObject(iObject[i]);
            
SendClientMessage(playerid, -1"You have collected the object! :D");
        }
    } 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)