Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- new ENABLE_AUTO_RETURN = 1; //Automatisch zur Ausgangsposition zurückkehren 1 = Ja | 0 = Nein
- #define RETURN_INTERVALL 3 //Sekunden bis das Objekt wieder zur Ausgangsposition zurückkehrt
- #define OBJECT_RANGE 20 //Entfernung vom Objekt
- #define MAX_ADDED_OBJECTS 30 // Maximale Anzahl der Objekte, die hinzugefügt werden können (Mehr werden nicht geladen)
- forward obj_return();
- new moved_id;
- enum o_Vars
- {
- _objectid,
- Float:s_x,
- Float:s_y,
- Float:s_z,
- Float:r_x,
- Float:r_y,
- Float:r_z,
- Float:e_x,
- Float:e_y,
- Float:e_z,
- }
- new obj_info[1][o_Vars] = {
- {3055,1588.591796875,-1638.009765625,14.624265670776,0.0,0.0,359.99645996094,1588.591796875,-1638.009765625,9.3742656707764} //Testtor am LSPD
- };
- public OnFilterScriptInit()
- {
- create_objects();
- return 1;
- }
- public OnFilterScriptExit()
- {
- destroy_objects();
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- if(ENABLE_AUTO_RETURN == 1)
- {
- SetTimer("obj_return",RETURN_INTERVALL*1000,0);
- moved_id = objectid;
- }
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- new id = GetNearestObject(playerid,OBJECT_RANGE);
- new listid=id-1;
- if(newkeys & KEY_YES)
- {
- MoveObject(id,obj_info[listid][e_x],obj_info[listid][e_y],obj_info[listid][e_z],2.0);
- }
- if(newkeys & KEY_NO)
- {
- if(ENABLE_AUTO_RETURN == 0)
- {
- MoveObject(id,obj_info[listid][s_x],obj_info[listid][s_y],obj_info[listid][s_z],2.0);
- }
- }
- return 1;
- }
- public obj_return()
- {
- new id = moved_id;
- new listid = moved_id -1;
- MoveObject(id,obj_info[listid][s_x],obj_info[listid][s_y],obj_info[listid][s_z],2.0);
- }
- stock GetNearestObject(playerid,Float:radius)
- {
- new Float:x,Float:y,Float:z, id=-1, Float:temp;
- for(new i;i<MAX_ADDED_OBJECTS;i++)
- {
- GetObjectPos(i,x,y,z);
- temp = GetPlayerDistanceFromPoint(playerid,x,y,z);
- if(temp < radius)
- {
- id = i;
- radius = temp;
- }
- }
- return id;
- }
- stock create_objects()
- {
- for(new id;id<MAX_ADDED_OBJECTS;id++)
- {
- CreateObject(obj_info[id][_objectid],obj_info[id][s_x],obj_info[id][s_y],obj_info[id][s_z],obj_info[id][r_x],obj_info[id][r_y],obj_info[id][r_z]);
- }
- }
- stock destroy_objects()
- {
- for(new id;id<MAX_ADDED_OBJECTS;id++){DestroyObject(id);}
- }
Advertisement
Add Comment
Please, Sign In to add comment