Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /****************************************
- ####### ######## ########
- # # # # # #
- # # # # # #
- # # # # # # #####
- # # ######## ######## #
- # # # # # #####
- # # # # # #
- ####### # # # #####
- >> OBJECTSTREAMER <<
- >> VERSION 3.0.0 <<
- >> STREAM ENGINE FS <<
- ****************************************/
- #define MAX_STREAMOBJ 2000 //Maximum Objects (Total)
- #define MAX_SLOTS 500 //Your Player Slots
- #define WARNING_COLOR 0xBBBBBBFF //Color Code
- #define LABEL_COLOR 0xBBBBBBFF //Color Code
- #define LABEL_COLOR2 0x00FF00FF //Color Code (Used while editing objects)
- #define DIALOG_ID 8072 //Should not be used in other Scripts
- #define DIALOG_ID2 8073 //Should not be used in other Scripts
- #define DIALOG_ID3 8074 //Should not be used in other Scripts
- #define DIALOG_ID4 8075 //Should not be used in other Scripts
- #define DIALOG_ID5 8076 //Should not be used in other Scripts
- #define DIALOG_ID6 8077 //Should not be used in other Scripts
- #define DIALOG_ID7 8078 //Should not be used in other Scripts
- #define DIALOG_ID8 8079 //Should not be used in other Scripts
- #define DIALOG_ID9 8080 //Should not be used in other Scripts
- #define DIALOG_ID10 8081 //Should not be used in other Scripts
- #define DIALOG_ID11 8082 //Should not be used in other Scripts
- #define DIALOG_ID12 8083 //Should not be used in other Scripts
- #define DIALOG_ID13 8084 //Should not be used in other Scripts
- #define DIALOG_ID14 8085 //Should not be used in other Scripts
- #define CONFIG_FILE "opa_objects/opa_objects.cfg" //Your configuration file
- #define LOG_FILE "opa_objects/opa_objects.log" //Your log file
- #define SAVEOBJ_FILE "opa_objects/savedobjects.txt"//Your file for /saveobj
- #define LOG_ACTIVE 1 //logfile On(1)/Off(0)
- #define TEXTDRAW 1 //Use a Textdraw while waiting for the map?
- #define SEND_WARN 1 //Send Warn-Message to Player?
- #define ANTIFAIL 1 //Enable Anti-Config-Fail?
- #define CALLBACK 0 //Enable "OnObjectStreamIn"?
- #define ROTATE 1 //Enable RotateObject?
- /***************************************/
- #include <a_samp>
- forward test();
- forward remoteObject(xx1,Float:xx2,Float:xx3,Float:xx4,Float:xx5,Float:xx6,Float:xx7);
- forward remoteVirtual(xx1,xx2);
- forward remoteMove(xx1,Float:xx2,Float:xx3,Float:xx4,Float:xx5);
- forward remoteSetPos(xx1,Float:xx2,Float:xx3,Float:xx4);
- forward remoteSetRot(xx1,Float:xx2,Float:xx3,Float:xx4);
- forward remoteDestroy(xx1);
- forward remoteStop(xx1);
- forward remoteConnectGM();
- forward remoteConnectFS();
- forward remoteMakeWait(playerid);
- forward remoteObjectEx();
- forward remoteDestroyEx();
- forward remoteIsStreamed(xx1,xx2);
- forward remoteGetPos(xx1,&Float:xx2,&Float:xx3,&Float:xx4);
- forward remoteGetRot(xx1,&Float:xx2,&Float:xx3,&Float:xx4);
- forward remoteGetModel(xx1,&xx2);
- forward remoteGetVw(xx1,&xx2);
- new obj,DRAW_DISTANCE=125,MAXPLAYEROBJ=254,kill,timeT=948;
- enum oen{mod,Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz,vw};
- new p[MAX_SLOTS][MAX_STREAMOBJ],o[MAX_STREAMOBJ][oen],bool:invalid[MAX_STREAMOBJ];
- new bool:warn[MAX_SLOTS],bool:wait[MAX_SLOTS],crash[MAX_SLOTS],admin=-1;
- new PlayerText3D:noob[MAX_STREAMOBJ],edit=-1,step=5,exobjects;
- new olist[10],anfang,bool:nichtnochmal,lastfile[50];
- #if ROTATE==1
- new Float:moveStep[MAX_STREAMOBJ][3],moveTime[MAX_STREAMOBJ],moveTimer[MAX_STREAMOBJ];
- forward mo(lol);
- forward remoteMoveRot(xx1,Float:xx2,Float:xx3,Float:xx4,xx5);
- #endif
- #if TEXTDRAW==1
- forward hideText(playerid);
- new Text:Textdraw0,Text:Textdraw1;
- #endif
- #define DINI_MAX_STRING 255
- #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
- public OnFilterScriptInit()
- {
- print("\n...Opas Objectstremer loading [1/2]...\n");
- #if LOG_ACTIVE==1
- if(!fexist(LOG_FILE))
- {
- new File:ffhandle=fopen(LOG_FILE,io_write);
- fclose(ffhandle);
- }
- #endif
- log("Starting streamer...");
- for(new n;n<MAX_OBJECTS;n++)o[n][vw]=-1;
- if(fexist(CONFIG_FILE))
- {
- new xz=strval(dini_Get(CONFIG_FILE,"drawdistance"));
- #if ANTIFAIL==1
- if(xz<5||xz>400)
- {
- log("[Antifail] drawdistance should be 5-400");
- xz=125;
- }
- #endif
- DRAW_DISTANCE=xz;
- xz=strval(dini_Get(CONFIG_FILE,"maxplayerobj"));
- #if ANTIFAIL==1
- if(xz<1||xz>254)
- {
- log("[Antifail] maxplayerobj should be 1-254");
- xz=254;
- }
- #endif
- MAXPLAYEROBJ=xz;
- xz=strval(dini_Get(CONFIG_FILE,"timer"));
- #if ANTIFAIL==1
- if(xz<200||xz>3500)
- {
- log("[Antifail] timer should be 200-3500");
- xz=948;
- }
- #endif
- timeT=xz;
- xz=strval(dini_Get(CONFIG_FILE,"step"));
- #if ANTIFAIL==1
- if(xz<1||xz>100)
- {
- log("[Antifail] step should be 1-100");
- xz=5;
- }
- #endif
- step=xz;
- }
- kill=SetTimer("test",timeT,1);
- #if TEXTDRAW==1
- Textdraw0 = TextDrawCreate(307.000000,181.000000,"~n~LOADING MAP...~n~PLEASE WAIT~n~_");
- TextDrawUseBox(Textdraw0,1);
- TextDrawBoxColor(Textdraw0,0x00000066);
- TextDrawTextSize(Textdraw0,0.000000,131.000000);
- TextDrawAlignment(Textdraw0,2);
- TextDrawBackgroundColor(Textdraw0,0xff000033);
- TextDrawFont(Textdraw0,1);
- TextDrawLetterSize(Textdraw0,0.299999,1.100000);
- TextDrawColor(Textdraw0,0xffffffff);
- TextDrawSetOutline(Textdraw0,1);
- TextDrawSetProportional(Textdraw0,1);
- TextDrawSetShadow(Textdraw0,1);
- Textdraw1 = TextDrawCreate(307.000000,181.000000,"~n~LOADING MAP...~n~DONE~n~_");
- TextDrawUseBox(Textdraw1,1);
- TextDrawBoxColor(Textdraw1,0x00000066);
- TextDrawTextSize(Textdraw1,0.000000,131.000000);
- TextDrawAlignment(Textdraw1,2);
- TextDrawBackgroundColor(Textdraw1,0x00ff0033);
- TextDrawFont(Textdraw1,1);
- TextDrawLetterSize(Textdraw1,0.299999,1.100000);
- TextDrawColor(Textdraw1,0xffffffff);
- TextDrawSetOutline(Textdraw1,1);
- TextDrawSetProportional(Textdraw1,1);
- TextDrawSetShadow(Textdraw1,1);
- #endif
- log("Successfully started!");
- return 1;
- }
- public OnFilterScriptExit()
- {
- fsexit();
- return 1;
- }
- public OnGameModeExit()
- {
- fsexit();
- SendRconCommand("reloadfs opa_objects");
- return 1;
- }
- stock fsexit()
- {
- for(new i;i<MAX_SLOTS;i++)
- {
- if(IsPlayerConnected(i))
- {
- for(new n;n<obj;n++)
- {
- if(p[i][n]!=0)DestroyPlayerObject(i,p[i][n]);
- }
- }
- }
- settings();
- KillTimer(kill);
- CallRemoteFunction("remoteExit","");
- }
- settings()
- {
- if(!fexist(CONFIG_FILE))
- {
- new File:ffhandle=fopen(CONFIG_FILE,io_write);
- fclose(ffhandle);
- }
- new stt[120];
- format(stt,sizeof stt,"%d",DRAW_DISTANCE);
- dini_Set(CONFIG_FILE,"drawdistance",stt);
- format(stt,sizeof stt,"%d",((!exobjects)?(MAXPLAYEROBJ):((MAXPLAYEROBJ+exobjects>254)?(254):(MAXPLAYEROBJ+exobjects))));
- dini_Set(CONFIG_FILE,"maxplayerobj",stt);
- format(stt,sizeof stt,"%d",timeT);
- dini_Set(CONFIG_FILE,"timer",stt);
- format(stt,sizeof stt,"%d",step);
- dini_Set(CONFIG_FILE,"step",stt);
- }
- public remoteIsStreamed(xx1,xx2)
- {
- if(!p[xx2][xx1])return 0;
- return 1;
- }
- public OnPlayerCommandText(playerid,cmdtext[])
- {
- if(!strcmp(cmdtext,"/streamer",true))
- {
- if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid,WARNING_COLOR,"You are not an Admin!");
- return mainmenu(playerid);
- }
- if(!strcmp(cmdtext,"/olist",true))
- {
- if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid,WARNING_COLOR,"You are not an Admin!");
- if(admin!=playerid)return SendClientMessage(playerid,WARNING_COLOR,"You have not activated the Mapeditor!");
- return objfile(lastfile);
- }
- dcmd(object,6,cmdtext);
- dcmd(saveobj,7,cmdtext);
- return 0;
- }
- explode(const strsrc[], strdest[][], delimiter)
- {
- new li,aNum,len;
- for(new i;i<=strlen(strsrc);i++)if(strsrc[i]==delimiter||i==strlen(strsrc))
- {
- len=strmid(strdest[aNum],strsrc,li,i,128);
- strdest[aNum][len]=0;
- li=i+1;
- aNum++;
- }
- return 1;
- }
- objfile(filenamex[])
- {
- new filename[50];
- format(filename,sizeof filename,"opa_objects/modelid/%s",filenamex);
- if(admin==-1)return 0;
- #define strlim 1024
- new dtxt[strlim];
- if(!fexist(filename))return 0;
- new File:xd=fopen(filename,io_read),zeile[100],zeila[2][100],i;
- for(;;)
- {
- fread(xd,zeile);
- if(i<anfang)
- {
- i++;
- continue;
- }
- if(!strlen(zeile))
- {
- nichtnochmal=true;
- break;
- }
- explode(zeile,zeila,'|');
- olist[i-anfang]=strval(zeila[0]);
- if(i!=anfang)format(dtxt,sizeof dtxt,"%s\n%s",dtxt,zeila[1]);
- else format(dtxt,sizeof dtxt,"%s",zeila[1]);
- i++;
- if(i==anfang+10)break;
- }
- anfang+=10;
- ShowPlayerDialog(admin,DIALOG_ID12,DIALOG_STYLE_LIST,"Opas Objectstreamer - Create Object",dtxt,"Create","Next page");
- fclose(xd);
- format(lastfile,sizeof lastfile,filenamex);
- return 1;
- }
- #if ROTATE==1
- public remoteMoveRot(xx1,Float:xx2,Float:xx3,Float:xx4,xx5)
- {
- if(moveTime[xx1]!=0)return 0;
- if(xx5%50!=0)return 0;
- moveTime[xx1]=xx5/50;
- moveStep[xx1][0]=(xx2-o[xx1][rx])/moveTime[xx1];
- moveStep[xx1][1]=(xx3-o[xx1][ry])/moveTime[xx1];
- moveStep[xx1][2]=(xx4-o[xx1][rz])/moveTime[xx1];
- moveTimer[xx1]=SetTimerEx("mo",50,1,"d",xx1);
- return 1;
- }
- public mo(lol)
- {
- remoteSetRot(lol,o[lol][rx]+moveStep[lol][0],o[lol][ry]+moveStep[lol][1],o[lol][rz]+moveStep[lol][2]);
- moveTime[lol]--;
- if(!moveTime[lol])
- {
- KillTimer(moveTimer[lol]);
- moveTimer[lol]=0;
- moveStep[lol][0]=0;
- moveStep[lol][1]=0;
- moveStep[lol][2]=0;
- }
- }
- #endif
- dcmd_saveobj(playerid,prm[])
- {
- if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid,WARNING_COLOR,"You are not an Admin!");
- if(admin!=playerid)return SendClientMessage(playerid,WARNING_COLOR,"You have not activated the Mapeditor!");
- new i,com[40];
- if(sscanf(prm,"dz",i,com))return SendClientMessage(playerid,WARNING_COLOR,"/saveobj [objectid] [comment]");
- if(i>=MAX_STREAMOBJ||invalid[i]||i<0)return SendClientMessage(playerid,WARNING_COLOR,"Invalid objectid!");
- if(!fexist(SAVEOBJ_FILE))
- {
- new File:ffhandle=fopen(SAVEOBJ_FILE,io_write);
- fclose(ffhandle);
- }
- new File:log2=fopen(SAVEOBJ_FILE,io_append);
- if(!log2)return SendClientMessage(playerid,WARNING_COLOR,"Failed saving");
- new ostr[300];
- format(ostr,sizeof ostr,"CreateObject(%d,%f,%f,%f,%f,%f,%f,%d);//%s\r\n",o[i][mod],o[i][x],o[i][y],o[i][z],o[i][rx],o[i][ry],o[i][rz],o[i][vw],com);
- fwrite(log2,ostr);
- fclose(log2);
- new send[128];
- if(!strlen(com))format(send,sizeof send,"Object %d saved",i);
- else format(send,sizeof send,"Object %d saved [%s]",i,com);
- return SendClientMessage(playerid,WARNING_COLOR,send);
- }
- mainmenu(playerid)
- {
- new inf[270],infoon[8];
- if(playerid==admin)format(infoon,sizeof infoon,"On");
- else if(admin!=-1)format(infoon,sizeof infoon,"In Use");
- else format(infoon,sizeof infoon,"Off");
- format(inf,sizeof inf,"Drawdistance: %d\nAnti-Crash warns: %d\nMaximum PlayerObjects: %d\nTimer: %d ms\nMapditor: %s\nSave Configuration\nSave Map...\nCreate Object here (Enter ID)\nCreate Object here (Objectlist)\nUtilization: Players:[%d%%] Server:[%d%%] Timer:[%d]\nInfo",DRAW_DISTANCE,allwarns(),MAXPLAYEROBJ,timeT,infoon,effort(),seffort(),teff());
- return ShowPlayerDialog(playerid,DIALOG_ID,DIALOG_STYLE_LIST,"Opas Objectstreamer",inf,"OK","Finish");
- }
- effort()
- {
- new Float:pro,pcount;
- for(new i;i<MAX_SLOTS;i++)if(IsPlayerConnected(i)&&!IsPlayerNPC(i))for(new n;n<obj;n++)if(p[i][n]!=0)pro++;
- for(new i;i<MAX_SLOTS;i++)if(IsPlayerConnected(i)&&!IsPlayerNPC(i))pcount++;
- pro=floatdiv(pro,pcount);
- new Float:tester=floatdiv(MAXPLAYEROBJ,100);
- pro=floatdiv(pro,tester);
- return floatround(pro);
- }
- seffort()
- {
- new pro,pcount,worst;
- for(new i;i<MAX_SLOTS;i++)if(IsPlayerConnected(i)&&!IsPlayerNPC(i))pcount++;
- pro=pcount*obj;
- worst=MAX_STREAMOBJ*MAX_SLOTS;
- new Float:ret=floatdiv(1,floatdiv(worst,pro));
- ret=ret*100;
- return floatround(ret);
- }
- teff()
- {
- new pcount;
- for(new i;i<MAX_SLOTS;i++)if(IsPlayerConnected(i)&&!IsPlayerNPC(i))pcount++;
- return pcount*obj;
- }
- dcmd_object(playerid,prm[])
- {
- if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid,WARNING_COLOR,"You are not an Admin!");
- if(admin!=playerid)return SendClientMessage(playerid,WARNING_COLOR,"You have not activated the Mapeditor!");
- new objid;
- if(sscanf(prm,"d",objid))return SendClientMessage(playerid,WARNING_COLOR,"/object [objectid]");
- if(objid>=obj||invalid[objid]||objid<0)return SendClientMessage(playerid,WARNING_COLOR,"Invalid objectid!");
- return showobject(playerid,objid);
- }
- showobject(playerid,oid)
- {
- new title[100],lol2[320];
- format(title,sizeof title,"Opas Objectstreamer - Object %d",oid);
- format(lol2,sizeof lol2,"World: %d\nX: %f\nY: %f\nZ: %f\nDelete",o[oid][vw],o[oid][x],o[oid][y],o[oid][z]);
- edit=oid;
- keep(edit);
- return ShowPlayerDialog(playerid,DIALOG_ID6,DIALOG_STYLE_LIST,title,lol2,"Change...","Done");
- }
- showposdia()
- {
- new dfg[300];
- format(dfg,sizeof dfg,"X +\nX -\nY +\nY -\nZ +\nZ -\nRotation\n-----------------\nStep: %d\nFaster\nSlower",step);
- return ShowPlayerDialog(admin,DIALOG_ID8,DIALOG_STYLE_LIST,"Opas Objectstreamer - Change Position",dfg,"OK","Done");
- }
- public OnDialogResponse(playerid,dialogid,response,listitem,inputtext[])
- {
- if(IsPlayerAdmin(playerid))
- {
- if(dialogid==DIALOG_ID&&response)
- {
- switch(listitem)
- {
- case 0:ShowPlayerDialog(playerid,DIALOG_ID2,DIALOG_STYLE_INPUT,"Opas Objectstreamer - Change Drawdistance","Enter a Number between 5 and 400","OK","Cancel");
- case 1:
- {
- new inf[400],name[MAX_PLAYER_NAME],Float:f[3],did;
- for(new i;i<MAX_SLOTS;i++)if(warn[i])
- {
- GetPlayerName(playerid,name,sizeof name);
- GetPlayerPos(playerid,f[0],f[1],f[2]);
- did=1;
- format(inf,sizeof inf,"%s%s[%d]: %.2f %.2f %.2f\n",inf,name,i,f[0],f[1],f[2]);
- }
- if(!did)format(inf,sizeof inf,"No player is warned");
- ShowPlayerDialog(playerid,DIALOG_ID3,DIALOG_STYLE_LIST,"Opas Objectstreamer - Warned Players",inf,"OK","Reset");
- }
- case 2:
- {
- new xt1[450];
- format(xt1,sizeof xt1,"Change Maximum PlayerObjects\n\nSamp Maximum:\t254\nGlobal Objects:\t%d\n-----------------------------------------\nBest:\t\t\t%d\nYour Setting:\t\t%d",exobjects,254-exobjects,MAXPLAYEROBJ);
- ShowPlayerDialog(playerid,DIALOG_ID4,DIALOG_STYLE_INPUT,"Opas Objectstreamer",xt1,"OK","Cancel");
- }
- case 3:ShowPlayerDialog(playerid,DIALOG_ID5,DIALOG_STYLE_INPUT,"Opas Objectstreamer - Change Timer Time","Enter a Number between 200 and 3500 ms","OK","Cancel");
- case 4:
- {
- if(admin==-1)
- {
- login(playerid);
- SendClientMessage(playerid,WARNING_COLOR,"Mapeditor enabled");
- }
- else if(admin==playerid)
- {
- logout();
- SendClientMessage(playerid,WARNING_COLOR,"Mapeditor disabled");
- }
- else
- {
- new ooo[128],nnng[MAX_PLAYER_NAME];
- GetPlayerName(admin,nnng,sizeof nnng);
- format(ooo,sizeof ooo,"Cannot load Mapeditor, %s has already activated it",nnng);
- SendClientMessage(playerid,WARNING_COLOR,ooo);
- }
- }
- case 5:
- {
- settings();
- SendClientMessage(playerid,WARNING_COLOR,"Configuration Saved");
- }
- case 6:ShowPlayerDialog(playerid,DIALOG_ID10,DIALOG_STYLE_INPUT,"Opas Objectstreamer - Save Map","Enter the filename\nMap will be saved as filename.txt","OK","Cancel");
- case 7:ShowPlayerDialog(playerid,DIALOG_ID9,DIALOG_STYLE_INPUT,"Opas Objectstreamer - Create Object here","Enter the modelid","OK","Cancel");
- case 8:
- {
- ShowPlayerDialog(playerid,DIALOG_ID11,DIALOG_STYLE_LIST,"Opas Objectstreamer - Create Object here","Weapons.txt\nNature.txt\nFun Stuff.txt\nBarriers.txt\nVarious.txt\nVarious II.txt\nVarious III.txt\nMisc.txt\nMisc II.txt\nOpen by name...","OK","Cancel");
- }
- case 10:ShowPlayerDialog(playerid,DIALOG_ID14,DIALOG_STYLE_LIST,"Opas Objectstreamer - Info","Script by KleinerOpa\n/streamer => Mainmenu\n/olist => Display the last Objectlist again\n/object [id] => Edit the object\n/saveobj => Save the object\nBugs? Need help? PM me in the forum","OK","Back");
- }
- return 1;
- }
- else if(dialogid==DIALOG_ID2)
- {
- if(!response)return mainmenu(playerid);
- new val=strval(inputtext);
- if(val<5||val>400)return SendClientMessage(playerid,WARNING_COLOR,"Error: Has to be between 5 and 400");
- DRAW_DISTANCE=val;
- new str[128];
- format(str,sizeof str,"New Drawdistance: %d",DRAW_DISTANCE);
- return SendClientMessage(playerid,WARNING_COLOR,str);
- }
- else if(dialogid==DIALOG_ID3&&!response)
- {
- for(new u;u<MAX_SLOTS;u++)warn[u]=false;
- return SendClientMessage(playerid,WARNING_COLOR,"Warnings deleted");
- }
- else if(dialogid==DIALOG_ID4)
- {
- if(!response)return mainmenu(playerid);
- new val=strval(inputtext);
- if(val<1||val>254-exobjects)
- {
- new xt1[128];
- format(xt1,sizeof xt1,"Error: Has to be between 1 and %d",254-exobjects);
- return SendClientMessage(playerid,WARNING_COLOR,xt1);
- }
- MAXPLAYEROBJ=val;
- new str[128];
- format(str,sizeof str,"New Maximum PlayerObjects: %d",MAXPLAYEROBJ);
- return SendClientMessage(playerid,WARNING_COLOR,str);
- }
- else if(dialogid==DIALOG_ID5)
- {
- if(!response)return mainmenu(playerid);
- new val=strval(inputtext);
- if(val<200||val>3500)return SendClientMessage(playerid,WARNING_COLOR,"Error: Has to be between 200 and 3500");
- timeT=val;
- KillTimer(kill);
- kill=SetTimer("test",timeT,1);
- new str[128];
- format(str,sizeof str,"New Timer Time: %d",timeT);
- return SendClientMessage(playerid,WARNING_COLOR,str);
- }
- else if(dialogid==DIALOG_ID6)
- {
- if(!response)
- {
- new fi=edit;
- edit=-1;
- keep(fi);
- return 1;
- }
- switch(listitem)
- {
- case 0:
- {
- ShowPlayerDialog(playerid,DIALOG_ID7,DIALOG_STYLE_INPUT,"Opas Objectstreamer - Change Virtualworld","Enter the new World","OK","Cancel");
- }
- case 1,2,3:
- {
- showposdia();
- }
- case 4:
- {
- remoteDestroy(edit);
- SendClientMessage(playerid,WARNING_COLOR,"Object Destroyed");
- edit=-1;
- }
- }
- return 1;
- }
- else if(dialogid==DIALOG_ID7)
- {
- if(!response)return showobject(playerid,edit);
- new val=strval(inputtext);
- if(val<-1)return SendClientMessage(playerid,WARNING_COLOR,"Error: Has to be between -1 and ...");
- remoteVirtual(edit,val);
- return showobject(playerid,edit);
- }
- else if(dialogid==DIALOG_ID8)
- {
- if(!response)return showobject(playerid,edit);
- new Float:step10=step/10.0;
- switch(listitem)
- {
- case 0:remoteSetPos(edit,o[edit][x]+step10,o[edit][y],o[edit][z]);
- case 1:remoteSetPos(edit,o[edit][x]-step10,o[edit][y],o[edit][z]);
- case 2:remoteSetPos(edit,o[edit][x],o[edit][y]+step10,o[edit][z]);
- case 3:remoteSetPos(edit,o[edit][x],o[edit][y]-step10,o[edit][z]);
- case 4:remoteSetPos(edit,o[edit][x],o[edit][y],o[edit][z]+step10);
- case 5:remoteSetPos(edit,o[edit][x],o[edit][y],o[edit][z]-step10);
- case 6:
- {
- new Float:lol;
- GetPlayerFacingAngle(playerid,lol);
- remoteSetRot(edit,o[edit][rx],o[edit][ry],lol);
- }
- case 9:step++;
- case 10:step--;
- }
- return showposdia();
- }
- else if(dialogid==DIALOG_ID9)
- {
- if(!response)return mainmenu(playerid);
- new val=strval(inputtext);
- if(val<1)return ShowPlayerDialog(playerid,DIALOG_ID9,DIALOG_STYLE_INPUT,"Opas Objectstreamer - Create Object here","Enter the modelid\n[[Enter a valid ID!]]","OK","Cancel");
- new Float:lol[4];
- GetPlayerPos(playerid,lol[0],lol[1],lol[2]);
- GetPlayerFacingAngle(playerid,lol[3]);
- new fish1=remoteObject(val,lol[0],lol[1],lol[2],0.0,0.0,lol[3]);
- if(!fish1)SendClientMessage(playerid,WARNING_COLOR,"Failed to create object");
- else
- {
- new rr[128];
- format(rr,sizeof rr,"Object %d created",obj-1);
- SendClientMessage(playerid,WARNING_COLOR,rr);
- }
- return mainmenu(playerid);
- }
- else if(dialogid==DIALOG_ID10)
- {
- if(!response)return mainmenu(playerid);
- new filen[65];
- format(filen,sizeof filen,"%s.txt",inputtext);
- if(fexist(filen))return SendClientMessage(playerid,WARNING_COLOR,"Error: this file already exists");
- new zeile[300];
- new File:bob=fopen(filen,io_write);
- if(!bob)
- {
- new gold1[128];
- format(gold1,sizeof gold1,"Mapfile [%s]: saving failed",filen);
- log(gold1);
- return SendClientMessage(playerid,WARNING_COLOR,gold1);
- }
- new lolh[120],wname[MAX_PLAYER_NAME],date[3];
- GetPlayerName(playerid,wname,sizeof wname);
- getdate(date[0],date[1],date[2]);
- format(lolh,sizeof lolh,"//Created with Opas Objectstreamer\r\n//%d.%d.%d by %s",date[2],date[1],date[0],wname);
- fwrite(bob,lolh);
- for(new i;i<obj;i++)if(!invalid[i])
- {
- format(zeile,sizeof zeile,"\r\nCreateObject(%d,%f,%f,%f,%f,%f,%f,%d);//%d",o[i][mod],o[i][x],o[i][y],o[i][z],o[i][rx],o[i][ry],o[i][rz],o[i][vw],i);
- fwrite(bob,zeile);
- }
- fclose(bob);
- new gold[128];
- format(gold,sizeof gold,"Saved mapfile [%s]",filen);
- log(gold);
- return SendClientMessage(playerid,WARNING_COLOR,gold);
- }
- else if(dialogid==DIALOG_ID11)
- {
- if(!response)return mainmenu(playerid);
- if(admin!=playerid)return SendClientMessage(playerid,WARNING_COLOR,"You have not activated the Mapeditor");
- new fxx[50],bool:self;
- switch(listitem)
- {
- case 0:fxx="Weapons.txt";
- case 1:fxx="Nature.txt";
- case 2:fxx="Fun Stuff.txt";
- case 3:fxx="Barriers.txt";
- case 4:fxx="Various.txt";
- case 5:fxx="Various II.txt";
- case 6:fxx="Various III.txt";
- case 7:fxx="Misc.txt";
- case 8:fxx="Misc II.txt";
- case 9:self=true;
- }
- if(self)return ShowPlayerDialog(playerid,DIALOG_ID13,DIALOG_STYLE_INPUT,"Opas Objectstreamer","Enter the filename\nDon't forget the extension!","OK","Cancel");
- objfile(fxx);
- return 1;
- }
- else if(dialogid==DIALOG_ID13)
- {
- if(!response)return mainmenu(playerid);
- if(!objfile(inputtext))return ShowPlayerDialog(playerid,DIALOG_ID13,DIALOG_STYLE_INPUT,"Opas Objectstreamer","Enter the filename\nDon't forget the extension!\n[[Error: That file doesn't exists!]]","OK","Cancel");
- return 1;
- }
- else if(dialogid==DIALOG_ID12)
- {
- if(!response)
- {
- if(!nichtnochmal)objfile(lastfile);
- else
- {
- nichtnochmal=false;
- anfang=0;
- }
- return 1;
- }
- nichtnochmal=false;
- anfang=0;
- new Float:lol[4];
- GetPlayerPos(playerid,lol[0],lol[1],lol[2]);
- GetPlayerFacingAngle(playerid,lol[3]);
- new fish1=remoteObject(olist[listitem],lol[0],lol[1],lol[2],0.0,0.0,lol[3]);
- if(!fish1)SendClientMessage(playerid,WARNING_COLOR,"Failed to create object");
- else
- {
- new rr[128];
- format(rr,sizeof rr,"Object %d created",obj-1);
- SendClientMessage(playerid,WARNING_COLOR,rr);
- }
- return 1;
- }
- else if(dialogid==DIALOG_ID14)return mainmenu(playerid);
- return 1;
- }
- return 0;
- }
- login(playerid)
- {
- admin=playerid;
- for(new i;i<obj;i++)if(!invalid[i])
- {
- new sr[250];
- format(sr,sizeof sr,"Object %d\nModel: %d World: %d\n[%.2f|%.2f|%.2f]",i,o[i][mod],o[i][vw],o[i][x],o[i][y],o[i][z]);
- noob[i]=CreatePlayer3DTextLabel(playerid,sr,LABEL_COLOR,o[i][x],o[i][y],o[i][z],35.0,INVALID_PLAYER_ID,INVALID_VEHICLE_ID,0);
- }
- return 1;
- }
- logout()
- {
- for(new i;i<obj;i++)if(!invalid[i])
- {
- DeletePlayer3DTextLabel(admin,noob[i]);
- }
- admin=-1;
- return 1;
- }
- public test()
- {
- for(new i;i<MAX_SLOTS;i++)
- {
- if(!IsPlayerConnected(i)||IsPlayerNPC(i))continue;
- for(new n;n<obj;n++)if(!invalid[n])
- {
- if((IsPlayerInRangeOfPoint(i,DRAW_DISTANCE,o[n][x],o[n][y],o[n][z]))&&((o[n][vw]==-1)||(GetPlayerVirtualWorld(i)==o[n][vw])))
- {
- if(!p[i][n])
- {
- if(crash[i]<=MAXPLAYEROBJ)
- {
- p[i][n]=CreatePlayerObject(i,o[n][mod],o[n][x],o[n][y],o[n][z],o[n][rx],o[n][ry],o[n][rz]);
- crash[i]++;
- #if CALLBACK==1
- CallRemoteFunction("OnObjectStreamIn","dd",i,n);
- #endif
- }
- else if(!warn[i])
- {
- #if SEND_WARN==1
- SendClientMessage(i,WARNING_COLOR,"Warning(opa_objectstreamer): Limit reached");
- #endif
- sendAdminWarn(i);
- warn[i]=true;
- }
- }
- }
- else if(p[i][n]!=0)
- {
- DestroyPlayerObject(i,p[i][n]);
- p[i][n]=0;
- crash[i]--;
- #if CALLBACK==1
- CallRemoteFunction("OnObjectStreamOut","dd",i,n);
- #endif
- }
- }
- if(wait[i])
- {
- wait[i]=false;
- TogglePlayerControllable(i,1);
- #if TEXTDRAW==1
- TextDrawHideForPlayer(i,Textdraw0);
- TextDrawShowForPlayer(i,Textdraw1);
- SetTimerEx("hideText",500,0,"d",i);
- #else
- GameTextForPlayer(i,"~w~LOADING MAP...~n~~g~DONE",500,6);
- #endif
- }
- }
- }
- #if TEXTDRAW==1
- public hideText(playerid)TextDrawHideForPlayer(playerid,Textdraw1);
- #endif
- public remoteObjectEx()
- {
- exobjects++;
- MAXPLAYEROBJ--;
- }
- public remoteDestroyEx()
- {
- exobjects--;
- if(MAXPLAYEROBJ<254)MAXPLAYEROBJ++;
- }
- allwarns()
- {
- new ret;
- for(new i;i<MAX_SLOTS;i++)if(warn[i])ret++;
- return ret;
- }
- sendAdminWarn(i)
- {
- new strr[128],namee[MAX_PLAYER_NAME],Float:b[3];
- GetPlayerName(i,namee,sizeof namee);
- GetPlayerPos(i,b[0],b[1],b[2]);
- format(strr,sizeof strr,"Warning(opa_objectstreamer@%s[%d]): Limit reached@%02f|%02f|%02f",namee,i,b[0],b[1],b[2]);
- for(new e;e<MAX_SLOTS;e++)if(IsPlayerAdmin(e))SendClientMessage(e,WARNING_COLOR,strr);
- format(strr,sizeof strr,"PlayerWarning: %s[%d]|%02f|%02f|%02f\n",namee,i,b[0],b[1],b[2]);
- log(strr);
- }
- keep(objx)
- {
- if(admin==-1)return 1;
- new sr[250];
- format(sr,sizeof sr,"Object %d\nModel: %d World: %d\n[%.2f|%.2f|%.2f]",objx,o[objx][mod],o[objx][vw],o[objx][x],o[objx][y],o[objx][z]);
- DeletePlayer3DTextLabel(admin,noob[objx]);
- if(objx!=edit)noob[objx]=CreatePlayer3DTextLabel(admin,sr,LABEL_COLOR,o[objx][x],o[objx][y],o[objx][z],35.0,INVALID_PLAYER_ID,INVALID_VEHICLE_ID,0);
- else noob[objx]=CreatePlayer3DTextLabel(admin,sr,LABEL_COLOR2,o[objx][x],o[objx][y],o[objx][z],35.0,INVALID_PLAYER_ID,INVALID_VEHICLE_ID,0);
- return 1;
- }
- public remoteObject(xx1,Float:xx2,Float:xx3,Float:xx4,Float:xx5,Float:xx6,Float:xx7)
- {
- if(obj>MAX_STREAMOBJ)return 0;
- o[obj][mod]=xx1;
- o[obj][x]=xx2;
- o[obj][y]=xx3;
- o[obj][z]=xx4;
- o[obj][rx]=xx5;
- o[obj][ry]=xx6;
- o[obj][rz]=xx7;
- if(admin!=-1)
- {
- new sr[250];
- format(sr,sizeof sr,"Object %d\nModel: %d World: %d\n[%.2f|%.2f|%.2f]",obj,o[obj][mod],o[obj][vw],o[obj][x],o[obj][y],o[obj][z]);
- noob[obj]=CreatePlayer3DTextLabel(admin,sr,LABEL_COLOR,o[obj][x],o[obj][y],o[obj][z],35.0,INVALID_PLAYER_ID,INVALID_VEHICLE_ID,0);
- }
- obj++;
- CallRemoteFunction("remoteNumber","d",obj);
- return 1;
- }
- public remoteVirtual(xx1,xx2)
- {
- o[xx1][vw]=xx2;
- keep(xx1);
- return 1;
- }
- public remoteMove(xx1,Float:xx2,Float:xx3,Float:xx4,Float:xx5)
- {
- for(new i;i<MAX_SLOTS;i++)
- {
- if(p[i][xx1]!=0)
- {
- MovePlayerObject(i,p[i][xx1],xx2,xx3,xx4,xx5);
- }
- }
- o[xx1][x]=xx2;
- o[xx1][y]=xx3;
- o[xx1][z]=xx4;
- keep(xx1);
- return 1;
- }
- public remoteSetPos(xx1,Float:xx2,Float:xx3,Float:xx4)
- {
- for(new i;i<MAX_SLOTS;i++)
- {
- if(p[i][xx1]!=0)
- {
- SetPlayerObjectPos(i,p[i][xx1],xx2,xx3,xx4);
- }
- }
- o[xx1][x]=xx2;
- o[xx1][y]=xx3;
- o[xx1][z]=xx4;
- keep(xx1);
- return 1;
- }
- public remoteSetRot(xx1,Float:xx2,Float:xx3,Float:xx4)
- {
- for(new i;i<MAX_SLOTS;i++)
- {
- if(p[i][xx1]!=0)
- {
- SetPlayerObjectRot(i,p[i][xx1],xx2,xx3,xx4);
- }
- }
- o[xx1][rx]=xx2;
- o[xx1][ry]=xx3;
- o[xx1][rz]=xx4;
- keep(xx1);
- return 1;
- }
- public remoteDestroy(xx1)
- {
- for(new i;i<MAX_SLOTS;i++)
- {
- if(p[i][xx1]!=0)
- {
- DestroyPlayerObject(i,p[i][xx1]);
- p[i][xx1]=0;
- crash[i]--;
- }
- }
- o[xx1][mod]=0;
- o[xx1][x]=0;
- o[xx1][y]=0;
- o[xx1][z]=0;
- o[xx1][rx]=0;
- o[xx1][ry]=0;
- o[xx1][rz]=0;
- o[xx1][vw]=-1;
- invalid[xx1]=true;
- if(admin!=-1)
- {
- DeletePlayer3DTextLabel(admin,noob[xx1]);
- }
- return 1;
- }
- public remoteStop(xx1)
- {
- for(new i;i<MAX_SLOTS;i++)
- {
- if(p[i][xx1]!=0)
- {
- StopPlayerObject(i,p[i][xx1]);
- }
- }
- }
- public remoteConnectGM()log("Gamemode Connected!");
- public remoteConnectFS()log("Filterscript Connected!");
- public remoteMakeWait(playerid)
- {
- if(wait[playerid])return 0;
- TogglePlayerControllable(playerid,0);
- wait[playerid]=true;
- #if TEXTDRAW==1
- TextDrawShowForPlayer(playerid,Textdraw0);
- #else
- GameTextForPlayer(playerid,"~w~LOADING MAP...~n~~r~PLEASE WAIT",timeT,6);
- #endif
- return 1;
- }
- log(string[])
- {
- #if LOG_ACTIVE==1
- new kkk[134],xtime[3];
- gettime(xtime[0],xtime[1],xtime[2]);
- format(kkk,sizeof kkk,"[%02d:%02d:%02d]%s\r\n",xtime[0],xtime[1],xtime[2],string);
- new File:fff=fopen(LOG_FILE,io_append);
- fwrite(fff,kkk);
- fclose(fff);
- #endif
- printf("[opa_objects] %s",string);
- }
- public OnPlayerDisconnect(playerid,reason)
- {
- if(playerid==admin)logout();
- for(new n;n<obj;n++)
- {
- if(p[playerid][n]!=0)
- {
- DestroyPlayerObject(playerid,p[playerid][n]);
- p[playerid][n]=0;
- }
- }
- crash[playerid]=0;
- warn[playerid]=false;
- wait[playerid]=false;
- }
- //----------DINI BY DRACOBLUE------------//
- dini_Set(filename[],key[],value[]) {
- new key_length = strlen(key);
- new value_length = strlen(value);
- if (key_length==0 || key_length+value_length+2>DINI_MAX_STRING) return false;
- new File:fohnd, File:fwhnd;
- new tmpres[DINI_MAX_STRING];
- new bool:wasset=false;
- format(tmpres,sizeof(tmpres),"%s.part",filename);
- fremove(tmpres);
- fohnd=fopen(filename,io_read);
- if (!fohnd) return false;
- fwhnd=fopen(tmpres,io_write);
- if (!fwhnd) {
- fclose(fohnd);
- return false;
- }
- while (fread(fohnd,tmpres)) {
- if (
- !wasset
- && tmpres[key_length]=='='
- && !strcmp(tmpres, key, true, key_length)
- ) {
- format(tmpres,sizeof(tmpres),"%s=%s",key,value);
- wasset=true;
- } else {
- DINI_StripNewLine(tmpres);
- }
- fwrite(fwhnd,tmpres);
- fwrite(fwhnd,"\r\n");
- }
- if (!wasset) {
- format(tmpres,sizeof(tmpres),"%s=%s",key,value);
- fwrite(fwhnd,tmpres);
- fwrite(fwhnd,"\r\n");
- }
- fclose(fohnd);
- fclose(fwhnd);
- format(tmpres,sizeof(tmpres),"%s.part",filename);
- if (DINI_fcopytextfile(tmpres,filename)) {
- return fremove(tmpres);
- }
- return false;
- }
- dini_Get(filename[],key[]) {
- new tmpres[DINI_MAX_STRING];
- new key_length = strlen(key);
- if (key_length==0 || key_length+2>DINI_MAX_STRING) return tmpres;
- new File:fohnd;
- fohnd=fopen(filename,io_read);
- if (!fohnd) return tmpres;
- while (fread(fohnd,tmpres)) {
- if (
- tmpres[key_length]=='='
- && !strcmp(tmpres, key, true, key_length)
- ) {
- DINI_StripNewLine(tmpres);
- strmid(tmpres, tmpres, key_length + 1, strlen(tmpres), DINI_MAX_STRING);
- fclose(fohnd);
- return tmpres;
- }
- }
- fclose(fohnd);
- return tmpres;
- }
- DINI_fcopytextfile(oldname[],newname[]) {
- new File:ohnd,File:nhnd;
- if (!fexist(oldname)) return false;
- ohnd=fopen(oldname,io_read);
- if (!ohnd) return false;
- nhnd=fopen(newname,io_write);
- if (!nhnd) {
- fclose(ohnd);
- return false;
- }
- new tmpres[DINI_MAX_STRING];
- while (fread(ohnd,tmpres)) {
- DINI_StripNewLine(tmpres);
- format(tmpres,sizeof(tmpres),"%s\r\n",tmpres);
- fwrite(nhnd,tmpres);
- }
- fclose(ohnd);
- fclose(nhnd);
- return true;
- }
- DINI_StripNewLine(string[]) {
- new len = strlen(string);
- if (string[0]==0) return ;
- if ((string[len - 1] == '\n') || (string[len - 1] == '\r')) {
- string[len - 1] = 0;
- if (string[0]==0) return ;
- if ((string[len - 2] == '\n') || (string[len - 2] == '\r')) string[len - 2] = 0;
- }
- }
- //----------SSCANF BY Y_LESS------------//
- stock sscanf(string[], format[], {Float,_}:...)
- {
- #if defined isnull
- if (isnull(string))
- #else
- if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
- #endif
- {
- return format[0];
- }
- #pragma tabsize 4
- new
- formatPos = 0,
- stringPos = 0,
- paramPos = 2,
- paramCount = numargs(),
- delim = ' ';
- while (string[stringPos] && string[stringPos] <= ' ')
- {
- stringPos++;
- }
- while (paramPos < paramCount && string[stringPos])
- {
- switch (format[formatPos++])
- {
- case '\0':
- {
- return 0;
- }
- case 'i', 'd':
- {
- new
- neg = 1,
- num = 0,
- ch = string[stringPos];
- if (ch == '-')
- {
- neg = -1;
- ch = string[++stringPos];
- }
- do
- {
- stringPos++;
- if ('0' <= ch <= '9')
- {
- num = (num * 10) + (ch - '0');
- }
- else
- {
- return -1;
- }
- }
- while ((ch = string[stringPos]) > ' ' && ch != delim);
- setarg(paramPos, 0, num * neg);
- }
- case 'h', 'x':
- {
- new
- num = 0,
- ch = string[stringPos];
- do
- {
- stringPos++;
- switch (ch)
- {
- case 'x', 'X':
- {
- num = 0;
- continue;
- }
- case '0' .. '9':
- {
- num = (num << 4) | (ch - '0');
- }
- case 'a' .. 'f':
- {
- num = (num << 4) | (ch - ('a' - 10));
- }
- case 'A' .. 'F':
- {
- num = (num << 4) | (ch - ('A' - 10));
- }
- default:
- {
- return -1;
- }
- }
- }
- while ((ch = string[stringPos]) > ' ' && ch != delim);
- setarg(paramPos, 0, num);
- }
- case 'c':
- {
- setarg(paramPos, 0, string[stringPos++]);
- }
- case 'f':
- {
- setarg(paramPos, 0, _:floatstr(string[stringPos]));
- }
- case 'p':
- {
- delim = format[formatPos++];
- continue;
- }
- case '\'':
- {
- new
- end = formatPos - 1,
- ch;
- while ((ch = format[++end]) && ch != '\'') {}
- if (!ch)
- {
- return -1;
- }
- format[end] = '\0';
- if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
- {
- if (format[end + 1])
- {
- return -1;
- }
- return 0;
- }
- format[end] = '\'';
- stringPos = ch + (end - formatPos);
- formatPos = end + 1;
- }
- case 'u':
- {
- new
- end = stringPos - 1,
- id = 0,
- bool:num = true,
- ch;
- while ((ch = string[++end]) && ch != delim)
- {
- if (num)
- {
- if ('0' <= ch <= '9')
- {
- id = (id * 10) + (ch - '0');
- }
- else
- {
- num = false;
- }
- }
- }
- if (num && IsPlayerConnected(id))
- {
- setarg(paramPos, 0, id);
- }
- else
- {
- #if !defined foreach
- #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
- #define __SSCANF_FOREACH__
- #endif
- string[end] = '\0';
- num = false;
- new
- name[MAX_PLAYER_NAME];
- id = end - stringPos;
- foreach (Player, playerid)
- {
- GetPlayerName(playerid, name, sizeof (name));
- if (!strcmp(name, string[stringPos], true, id))
- {
- setarg(paramPos, 0, playerid);
- num = true;
- break;
- }
- }
- if (!num)
- {
- setarg(paramPos, 0, INVALID_PLAYER_ID);
- }
- string[end] = ch;
- #if defined __SSCANF_FOREACH__
- #undef foreach
- #undef __SSCANF_FOREACH__
- #endif
- }
- stringPos = end;
- }
- case 's', 'z':
- {
- new
- i = 0,
- ch;
- if (format[formatPos])
- {
- while ((ch = string[stringPos++]) && ch != delim)
- {
- setarg(paramPos, i++, ch);
- }
- if (!i)
- {
- return -1;
- }
- }
- else
- {
- while ((ch = string[stringPos++]))
- {
- setarg(paramPos, i++, ch);
- }
- }
- stringPos--;
- setarg(paramPos, i, '\0');
- }
- default:
- {
- continue;
- }
- }
- while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
- {
- stringPos++;
- }
- while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
- {
- stringPos++;
- }
- paramPos++;
- }
- do
- {
- if ((delim = format[formatPos++]) > ' ')
- {
- if (delim == '\'')
- {
- while ((delim = format[formatPos++]) && delim != '\'') {}
- }
- else if (delim != 'z')
- {
- return delim;
- }
- }
- }
- while (delim > ' ');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement