Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <zcmd>
- #include <sscanf2>
- #include <dini>
- #define MAX_CCTV 100
- new PlayerText:Textdraw0[MAX_PLAYERS];
- new PlayerText:Textdraw1[MAX_PLAYERS];
- new PlayerText:Textdraw3[MAX_PLAYERS];
- new PlayerText:Textdraw4[MAX_PLAYERS];
- enum CCTVINFO
- {
- ID,
- Float:cx,
- Float:cy,
- Float:cz,
- Float:rx,
- Float:ry,
- Float:rz,
- OBJ1,
- vw
- }
- new cInfo[MAX_CCTV][CCTVINFO];
- enum PLAYERINFO
- {
- Float:px,
- Float:py,
- Float:pz,
- pvw,
- bool:watchel
- }
- new plInfo[MAX_PLAYERS][PLAYERINFO];
- new ccform[200];
- new ccdbform[20];
- new ccdb;
- new playered[MAX_PLAYERS];
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" CCTV by Genki");
- print("--------------------------------------\n");
- format(ccdbform,sizeof(ccdbform),"/cctv/db.ini");
- if(!dini_Exists(ccdbform))
- {
- dini_Create(ccdbform);
- ccdb=0;
- dini_IntSet(ccdbform,"Db",ccdb);
- }
- else
- {
- ccdb=dini_Int(ccdbform,"Db");
- }
- for(new i=1;i<=ccdb;i++)
- {
- format(ccform,sizeof(ccform),"/cctv/%i.ini",i);
- cInfo[i][cx]=dini_Float(ccform,"x");
- cInfo[i][cy]=dini_Float(ccform,"y");
- cInfo[i][cz]=dini_Float(ccform,"z");
- cInfo[i][rx]=dini_Float(ccform,"rx");
- cInfo[i][ry]=dini_Float(ccform,"ry");
- cInfo[i][rz]=dini_Float(ccform,"rz");
- cInfo[i][ID]=dini_Int(ccform,"id");
- cInfo[i][OBJ1]=CreateObject(2921, cInfo[i][cx], cInfo[i][cy],cInfo[i][cz], cInfo[i][rx], cInfo[i][ry], cInfo[i][rz]);
- cInfo[i][vw]=dini_Int(ccform,"vw");
- }
- return 1;
- }
- public OnFilterScriptExit()
- {
- dini_IntSet(ccdbform,"Db",ccdb);
- for(new i=1;i<=ccdb;i++)
- {
- format(ccform,sizeof(ccform),"/cctv/%i.ini",i);
- DestroyObject(cInfo[i][OBJ1]);
- dini_IntSet(ccform,"id",cInfo[i][ID]);
- dini_FloatSet(ccform,"x",cInfo[i][cx]);
- dini_FloatSet(ccform,"y",cInfo[i][cy]);
- dini_FloatSet(ccform,"z",cInfo[i][cz]);
- dini_FloatSet(ccform,"rx",cInfo[i][rx]);
- dini_FloatSet(ccform,"ry",cInfo[i][ry]);
- dini_FloatSet(ccform,"rz",cInfo[i][rz]);
- dini_IntSet(ccform,"vw",cInfo[i][vw]);
- }
- return 1;
- }
- stock Float:GetPosInFrontOfCam(camid,&Float:x,&Float:y,Float:distance)
- {
- new Float:a;
- x=cInfo[camid][cx];
- y=cInfo[camid][cy];
- a=cInfo[camid][rz]+45;
- x += (distance * floatsin(-a, degrees));
- y += (distance * floatcos(-a, degrees));
- return a;
- }
- public OnPlayerConnect(playerid)
- {
- Textdraw0[playerid] = CreatePlayerTextDraw(playerid, 639.555541, 423.111083, "LD_SPAC:white");
- PlayerTextDrawLetterSize(playerid, Textdraw0[playerid], 0.000000, 0.000000);
- PlayerTextDrawTextSize(playerid, Textdraw0[playerid], -639.555541, 24.888916);
- PlayerTextDrawAlignment(playerid, Textdraw0[playerid], 1);
- PlayerTextDrawColor(playerid, Textdraw0[playerid], -1061109505);
- PlayerTextDrawSetShadow(playerid, Textdraw0[playerid], 0);
- PlayerTextDrawSetOutline(playerid, Textdraw0[playerid], 0);
- PlayerTextDrawBackgroundColor(playerid, Textdraw0[playerid], -2139062017);
- PlayerTextDrawFont(playerid, Textdraw0[playerid], 4);
- Textdraw1[playerid] = CreatePlayerTextDraw(playerid, 12.444426, 427.591003, "Camid:");
- PlayerTextDrawLetterSize(playerid, Textdraw1[playerid], 0.495333, 1.644800);
- PlayerTextDrawAlignment(playerid, Textdraw1[playerid], 1);
- PlayerTextDrawColor(playerid, Textdraw1[playerid], 255);
- PlayerTextDrawSetShadow(playerid, Textdraw1[playerid], 1);
- PlayerTextDrawSetOutline(playerid, Textdraw1[playerid], 0);
- PlayerTextDrawBackgroundColor(playerid, Textdraw1[playerid], 51);
- PlayerTextDrawFont(playerid, Textdraw1[playerid], 1);
- PlayerTextDrawSetProportional(playerid, Textdraw1[playerid], 1);
- Textdraw3[playerid] = CreatePlayerTextDraw(playerid, 612.889282, 401.208770, "LD_BEAT:right");
- PlayerTextDrawLetterSize(playerid, Textdraw3[playerid], 0.000000, 0.000000);
- PlayerTextDrawTextSize(playerid, Textdraw3[playerid], 25.333356, 13.439996);
- PlayerTextDrawAlignment(playerid, Textdraw3[playerid], 1);
- PlayerTextDrawColor(playerid, Textdraw3[playerid], 255);
- PlayerTextDrawSetShadow(playerid, Textdraw3[playerid], 0);
- PlayerTextDrawSetOutline(playerid, Textdraw3[playerid], 0);
- PlayerTextDrawFont(playerid, Textdraw3[playerid], 4);
- PlayerTextDrawSetSelectable(playerid, Textdraw3[playerid], true);
- Textdraw4[playerid] = CreatePlayerTextDraw(playerid, 586.666992, 401.208923, "LD_BEAT:left");
- PlayerTextDrawLetterSize(playerid, Textdraw4[playerid], 0.000000, 0.000000);
- PlayerTextDrawTextSize(playerid, Textdraw4[playerid], 24.888872, 12.942211);
- PlayerTextDrawAlignment(playerid, Textdraw4[playerid], 1);
- PlayerTextDrawColor(playerid, Textdraw4[playerid], 255);
- PlayerTextDrawSetShadow(playerid, Textdraw4[playerid], 0);
- PlayerTextDrawSetOutline(playerid, Textdraw4[playerid], 0);
- PlayerTextDrawFont(playerid, Textdraw4[playerid], 4);
- PlayerTextDrawSetSelectable(playerid, Textdraw4[playerid], true);
- PlayerTextDrawHide(playerid, Textdraw0[playerid]);
- PlayerTextDrawHide(playerid, Textdraw1[playerid]);
- PlayerTextDrawHide(playerid, Textdraw3[playerid]);
- PlayerTextDrawHide(playerid, Textdraw4[playerid]);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- PlayerTextDrawDestroy(playerid, Textdraw0[playerid]);
- PlayerTextDrawDestroy(playerid, Textdraw1[playerid]);
- PlayerTextDrawDestroy(playerid, Textdraw3[playerid]);
- PlayerTextDrawDestroy(playerid, Textdraw4[playerid]);
- return 1;
- }
- public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
- {
- new Float:x,Float:y;
- if(playertextid == Textdraw3[playerid])
- {
- if(playered[playerid]==ccdb)
- {
- SendClientMessage(playerid,-1,"Nincs tovább");
- }
- else
- {
- playered[playerid]++;
- GetPosInFrontOfCam(playered[playerid],x,y,15);
- SetPlayerVirtualWorld(playerid,cInfo[playered[playerid]][vw]);
- SetPlayerPos(playerid,cInfo[playered[playerid]][cx],cInfo[playered[playerid]][cy],cInfo[playered[playerid]][cz]+500);
- SetPlayerCameraPos(playerid,cInfo[playered[playerid]][cx],cInfo[playered[playerid]][cy],cInfo[playered[playerid]][cz]+1.1);
- SetPlayerCameraLookAt(playerid,x,y,cInfo[playered[playerid]][cz]-0.1);
- new newtext[11];
- format(newtext,sizeof(newtext),"Camid:%i",playered[playerid]);
- PlayerTextDrawSetString(playerid, Textdraw1[playerid], newtext);
- }
- }
- if(playertextid == Textdraw4[playerid])
- {
- if(playered[playerid]==1)
- {
- SendClientMessage(playerid,-1,"Nincs tovább");
- }
- else
- {
- playered[playerid]--;
- GetPosInFrontOfCam(playered[playerid],x,y,15);
- SetPlayerVirtualWorld(playerid,cInfo[playered[playerid]][vw]);
- SetPlayerPos(playerid,cInfo[playered[playerid]][cx],cInfo[playered[playerid]][cy],cInfo[playered[playerid]][cz]+500);
- SetPlayerCameraPos(playerid,cInfo[playered[playerid]][cx],cInfo[playered[playerid]][cy],cInfo[playered[playerid]][cz]+1.1);
- SetPlayerCameraLookAt(playerid,x,y,cInfo[playered[playerid]][cz]-0.1);
- new newtext[11];
- format(newtext,sizeof(newtext),"Camid:%i",playered[playerid]);
- PlayerTextDrawSetString(playerid, Textdraw1[playerid], newtext);
- }
- }
- return 1;
- }
- stock createcam(aid,Float:ax,Float:ay,Float:az,virw)
- {
- format(ccform,sizeof(ccform),"/cctv/%i.ini",aid);
- dini_Create(ccform);
- {
- cInfo[aid][cx]=ax;
- cInfo[aid][cy]=ay;
- cInfo[aid][cz]=az;
- cInfo[aid][ID]=aid;
- cInfo[aid][vw]=virw;
- dini_IntSet(ccform,"id",aid);
- dini_FloatSet(ccform,"x",ax);
- dini_FloatSet(ccform,"y",ay);
- dini_FloatSet(ccform,"z",az);
- cInfo[aid][OBJ1]=CreateObject(2921, ax, ay, az, 0.00000, 0.00000, 0.00000);
- }
- return 1;
- }
- CMD:createcc(playerid)
- {
- new Float:x, Float:y, Float:z;
- new virtw;
- GetPlayerPos(playerid,x,y,z);
- ccdb++;
- virtw=GetPlayerVirtualWorld(playerid);
- createcam(ccdb,x,y,z,virtw);
- dini_IntSet(ccdbform,"Db",ccdb);
- return 1;
- }
- CMD:watchcam(playerid,params[])
- {
- new Float:x,Float:y;
- playered[playerid]=0;
- new camid;
- if(sscanf(params,"i",camid)) return SendClientMessage(playerid,-1,"Használd /watchcam[camid]");
- if(camid>0 && camid<=ccdb)
- {
- if(plInfo[playerid][watchel]==false)
- {
- plInfo[playerid][watchel]=true;
- x=cInfo[camid][cx];
- y=cInfo[camid][cy];
- GetPlayerPos(playerid,plInfo[playerid][px],plInfo[playerid][py],plInfo[playerid][pz]);
- plInfo[playerid][pvw]=GetPlayerVirtualWorld(playerid);
- SetPlayerPos(playerid,cInfo[camid][cx],cInfo[camid][cy],cInfo[camid][cz]+500);
- GetPosInFrontOfCam(camid,x,y,15);
- TogglePlayerControllable(playerid,false);
- SetPlayerVirtualWorld(playerid,cInfo[camid][vw]);
- SetPlayerCameraPos(playerid,cInfo[camid][cx],cInfo[camid][cy],cInfo[camid][cz]+1.1);
- SetPlayerCameraLookAt(playerid,x,y,cInfo[camid][cz]-0.1);
- playered[playerid]=camid;
- new newtext[11];
- format(newtext,sizeof(newtext),"Camid:%i",camid);
- PlayerTextDrawSetString(playerid, Textdraw1[playerid], newtext);
- PlayerTextDrawShow(playerid, Textdraw1[playerid]);
- PlayerTextDrawShow(playerid, Textdraw0[playerid]);
- PlayerTextDrawShow(playerid, Textdraw3[playerid]);
- PlayerTextDrawShow(playerid, Textdraw4[playerid]);
- SelectTextDraw(playerid, 0xFF4040AA);
- }
- else
- {
- SendClientMessage(playerid,-1,"Már nézed a kamerát, nyilakkal váltogass");
- }
- }
- else
- {
- SendClientMessage(playerid,-1,"Nincs ilyen kamera");
- }
- return 1;
- }
- CMD:exitcam(playerid)
- {
- SetPlayerPos(playerid,plInfo[playerid][px],plInfo[playerid][py],plInfo[playerid][pz]);
- SetPlayerVirtualWorld(playerid,plInfo[playerid][pvw]);
- TogglePlayerControllable(playerid,true);
- SetCameraBehindPlayer(playerid);
- CancelSelectTextDraw(playerid);
- plInfo[playerid][watchel]=false;
- PlayerTextDrawHide(playerid, Textdraw0[playerid]);
- PlayerTextDrawHide(playerid, Textdraw1[playerid]);
- PlayerTextDrawHide(playerid, Textdraw3[playerid]);
- PlayerTextDrawHide(playerid, Textdraw4[playerid]);
- return 1;
- }
- CMD:eobj(playerid,params[])
- {
- new id;
- if(sscanf(params,"i",id)) return SendClientMessage(playerid,-1,"Használd /editcc[camid]");
- playered[playerid]=id;
- EditObject(playerid,cInfo[id][OBJ1]);
- return 1;
- }
- public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
- {
- if(response == EDIT_RESPONSE_FINAL)
- {
- cInfo[playered[playerid]][cx]=fX;
- cInfo[playered[playerid]][cy]=fY;
- cInfo[playered[playerid]][cz]=fZ;
- cInfo[playered[playerid]][rx]=fRotX;
- cInfo[playered[playerid]][ry]=fRotY;
- cInfo[playered[playerid]][rz]=fRotZ;
- dini_FloatSet(ccform,"x",cInfo[playered[playerid]][cx]);
- dini_FloatSet(ccform,"y",cInfo[playered[playerid]][cy]);
- dini_FloatSet(ccform,"z",cInfo[playered[playerid]][cz]);
- dini_FloatSet(ccform,"rx",cInfo[playered[playerid]][rx]);
- dini_FloatSet(ccform,"ry",cInfo[playered[playerid]][ry]);
- dini_FloatSet(ccform,"rz",cInfo[playered[playerid]][rz]);
- playered[playerid]=0;
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement