Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <YSI\y_ini>
- #include <zcmd>
- #include <streamer>
- #include <sscanf2>
- #define COLOR_BLUE 0x009AE5B0
- #define COLOR_YELLOW 0xFFFF00B4
- #define COLOR_RED 0xB40000B5
- #define MAX_OBJ 1000
- #define Path "Objects/%d.ini"
- new bool:ObjCreated[MAX_OBJ];
- new objectz[MAX_OBJ];
- enum obinfo{
- model,
- Float:posx,
- Float:posy,
- Float:posz,
- Float:rotx,
- Float:roty,
- Float:rotz,
- };
- new gobject[MAX_OBJ][obinfo];
- CMD:createobject(playerid,params[]){
- new modelid;
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED,"Sorry but you are not authorised to use this command");
- if(sscanf(params, "i" ,modelid)) return SendClientMessage(playerid, COLOR_YELLOW,"Usage: /createobject <Model ID>");
- new Float:x,Float:y,Float:z;
- GetPlayerPos(playerid,x,y,z);
- for(new i=0; i<MAX_OBJ;i++){
- if(!ObjCreated[i]){
- objectz[i]=CreateDynamicObject(modelid,x+2,y,z,0,0,0);
- new str[128];
- format(str,sizeof(str),"You have created a object(ID:%d) with Model ID:%d",i,modelid);
- SendClientMessage(playerid, COLOR_BLUE,str);
- new Float:x1,Float:y1,Float:z1;
- GetObjectPos(objectz[i],x1,y1,z1);
- new Float:x2,Float:y2,Float:z2;
- GetObjectRot(objectz[i],x2,y2,z2);
- ObjCreated[i]=true;
- gobject[i][model]=modelid;
- gobject[i][posx]=x1;
- gobject[i][posy]=y1;
- gobject[i][posz]=z1;
- gobject[i][rotx]=x2;
- gobject[i][roty]=y2;
- gobject[i][rotz]=z2;
- SaveFile(i);
- break;
- }
- }
- return 1;
- }
- CMD:editobject(playerid,params[]){
- new id;
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED,"Sorry but you are not authorised to use this command");
- if(sscanf(params,"i",id)) return SendClientMessage(playerid, COLOR_YELLOW,"Usage: /editobject <ID>");
- if(!IsValidDynamicObject(objectz[id])) return SendClientMessage(playerid, COLOR_RED,"Failed: That Object ID does not exist");
- EditDynamicObject(playerid, objectz[id]);
- new str[128];
- format(str,sizeof(str),"Success: You are editing object ID: %d",id);
- SendClientMessage(playerid, COLOR_YELLOW,str);
- return 1;
- }
- CMD:destroyobject(playerid,params[]){
- new id;
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED,"Sorry but you are not authorised to use this command");
- if(sscanf(params,"i",id)) return SendClientMessage(playerid, COLOR_YELLOW,"Usage: /destroyobject <ID>");
- if(!IsValidDynamicObject(objectz[id])) return SendClientMessage(playerid, COLOR_RED,"Failed: That Object ID does not exist");
- DestroyDynamicObject(objectz[id]);
- new str[128];
- format(str,sizeof(str),"Success: You have deleted object ID:%d",id);
- SendClientMessage(playerid, COLOR_RED,str);
- ObjCreated[id]=false;
- return 1;
- }
- forward LoadObjects(i, name[], value[]);
- public LoadObjects(i, name[], value[]){
- INI_Int("model",gobject[i][model]);
- INI_Float("posx",gobject[i][posx]);
- INI_Float("posy",gobject[i][posy]);
- INI_Float("posz",gobject[i][posz]);
- INI_Float("rotx",gobject[i][rotx]);
- INI_Float("roty",gobject[i][roty]);
- INI_Float("rotz",gobject[i][rotz]);
- return 1;
- }
- SavePath(objectid){
- new str[10];
- format(str, sizeof(str),Path,objectid);
- return str;
- }
- forward SaveFile(objectid);
- public SaveFile(objectid){
- new INI:file=INI_Open(SavePath(objectid));
- INI_WriteInt(file,"model",gobject[objectid][model]);
- INI_WriteFloat(file,"posx",gobject[objectid][posx]);
- INI_WriteFloat(file,"posy",gobject[objectid][posy]);
- INI_WriteFloat(file,"posz",gobject[objectid][posz]);
- INI_WriteFloat(file,"rotx",gobject[objectid][rotx]);
- INI_WriteFloat(file,"roty",gobject[objectid][roty]);
- INI_WriteFloat(file,"rotz",gobject[objectid][rotz]);
- INI_Close(file);
- return 1;
- }
Add Comment
Please, Sign In to add comment