Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //--------------------------------------------------------------------------------------------
- //------------------------------- Jochem Non Playing Character -------------------------------
- //------------------------------------------- J-NPC ------------------------------------------
- //------------------------------- Copyright © GTA Productions --------------------------------
- //--------------------------------------------------------------------------------------------
- #include <a_samp>
- #define ONFOOT 2
- #define INVEHICLE 1
- #define COLOR_WHITE -1
- #define COLOR_RED 0xFF0F0FFF
- #define COLOR_YELLOW 0xFFFF00FF
- #define DIALOG_REC 6769
- #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
- stock Playername(playerid)
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,name,sizeof(name));
- return name;
- }
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Successfully loaded J-NPC [by Jochemd] ");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("\n--------------------------------------");
- print(" Successfully unloaded J-NPC [by Jochemd] ");
- print("--------------------------------------\n");
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- dcmd(npcrecord,9,cmdtext);
- dcmd(stoprecord,10,cmdtext);
- return 0;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == DIALOG_REC && response == 1)
- {
- new filename[31],rectype = GetPVarInt(playerid,"RecType");
- GetPVarString(playerid,"FileName",filename,31);
- if(rectype == INVEHICLE)
- {
- SetPVarInt(playerid,"Recording",INVEHICLE);
- SetPVarInt(playerid,"npcvehid",GetVehicleModel(GetPlayerVehicleID(playerid)));
- StartRecordingPlayerData(playerid,PLAYER_RECORDING_TYPE_DRIVER,filename);
- }
- else
- {
- SetPVarInt(playerid,"Recording",ONFOOT);
- StartRecordingPlayerData(playerid,PLAYER_RECORDING_TYPE_DRIVER,filename);
- }
- SendClientMessage(playerid,COLOR_WHITE,"Succes: You have started recording. To stop, type /stoprecord.");
- printf("J-NPC: %s started recording a NPC. Type: %d",Playername(playerid),rectype);
- return 1;
- }
- return 1;
- }
- dcmd_npcrecord(playerid,params[])
- {
- if(IsPlayerAdmin(playerid))
- {
- if(strlen(params) > 0 && strlen(params) < 31)
- {
- new str[35];
- format(str,sizeof(str),"%s.rec",params);
- if(!fexist(str))
- {
- new st = GetPlayerState(playerid);
- if(st == PLAYER_STATE_DRIVER || st == PLAYER_STATE_PASSENGER)
- {
- SetPVarInt(playerid,"RecType",INVEHICLE);
- ShowPlayerDialog(playerid,DIALOG_REC,DIALOG_STYLE_MSGBOX,"J-NPC","Do you want to record a NPC\nin this vehicle?","Yes, start","No, wait");
- }
- else if(st == PLAYER_STATE_ONFOOT)
- {
- SetPVarInt(playerid,"RecType",ONFOOT);
- ShowPlayerDialog(playerid,DIALOG_REC,DIALOG_STYLE_MSGBOX,"J-NPC","Do you want to record a NPC\non foot?","Yes, start","No, wait");
- }
- SetPVarString(playerid,"FileName",params);
- return 1;
- }
- else return SendClientMessage(playerid,COLOR_RED,"Error: File already exists, please choose another name.");
- }
- else return SendClientMessage(playerid,COLOR_RED,"Error: Please specify a filename longer than 0 characters and shorter than 31 characters.");
- }
- else return 0;
- }
- dcmd_stoprecord(playerid,params[])
- {
- #pragma unused params
- new Recording = GetPVarInt(playerid,"Recording");
- if(Recording != 0)
- {
- new tick,File:file,str[700],filename[31];
- StopRecordingPlayerData(playerid);
- SendClientMessage(playerid,COLOR_WHITE,"Succes: You have successfully stopped recording. Please wait, your script is being built...");
- tick = GetTickCount();
- GetPVarString(playerid,"FileName",filename,31);
- format(str,sizeof(str),"%s.pwn",filename);
- file = fopen(str,io_write);
- format(str,sizeof(str),"#define RECORDING \"%s\"\r\n#define RECORDING_TYPE %d\r\n \r\n",filename,Recording);
- fwrite(file,str);
- fwrite(file,"#include <a_npc>\nmain() {}\r\n \r\npublic OnRecordingPlaybackEnd() StartRecordingPlayback(RECORDING_TYPE, RECORDING);\r\n \r\n#if RECORDING_TYPE == 1\r\n public OnNPCEnterVehicle(vehicleid, seatid) StartRecordingPlayback(RECORDING_TYPE, RECORDING);\r\n public OnNPCExitVehicle() StopRecordingPlayback();\r\n");
- fwrite(file,"#else\r\n public OnNPCSpawn() StartRecordingPlayback(RECORDING_TYPE, RECORDING);\r\n#endif");
- fclose(file);
- format(str,sizeof(str),"%s_gamemode_script.txt",filename);
- file = fopen(str,io_write);
- if(GetPVarInt(playerid,"Recording") == ONFOOT)
- {
- format(str,sizeof(str),"// Put the script down here in your gamemode. You might have to merge functions.\r\n \r\npublic OnGameModeInit()\r\n{\r\n ConnectNPC(\"npc_name_here\",%s);\r\n return 1;\r\n}",filename);
- fwrite(file,str);
- }
- else
- {
- format(str,sizeof(str),"// Put the script down here in your gamemode. You might have to merge functions. Also, don't forget to replace 'npc_name_here' with the name of the NPC ingame.\r\n\r\nnew npc_name_here_vehicle; \r\n\r\npublic OnGameModeInit()\r\n{\r\n npc_name_here_vehicle = CreateVehicle(%d,0.0,0.0,0.0,0.0,-1,-1,-1);\r\n ConnectNPC(\"npc_name_here\",%s);\r\n return 1;\r\n}\r\n \r\npublic OnPlayerSpawn(playerid)\r\n{\r\n",GetPVarInt(playerid,"npcvehid"),filename);
- fwrite(file,str);
- fwrite(file," if(IsPlayerNPC(playerid))\r\n {\r\n new name[MAX_PLAYER_NAME];\r\n GetPlayerName(playerid,name,sizeof(name));\r\n if(!strcmp(name,\"npc_name_here\",false))\r\n {\r\n PutPlayerInVehicle(playerid,npc_name_here_vehicle,0);\r\n }\r\n return 1;\r\n }\r\n return 1;\r\n}");
- }
- fclose(file);
- printf("Succes: Script has been built in %d ms.",GetTickCount() - tick);
- SendClientMessage(playerid,COLOR_YELLOW,"Now all you need to do is move a couple of files;");
- format(str,sizeof(str),"- %s.rec has to be moved to /server_root/npcmodes/recordings.",filename);
- SendClientMessage(playerid,COLOR_WHITE,str);
- format(str,sizeof(str),"- %s.pwn has to be moved to /server_root/npcmodes.",filename);
- SendClientMessage(playerid,COLOR_WHITE,str);
- format(str,sizeof(str)," Also, don't forget to look in %s.txt which contains script to run the NPC.",filename);
- SendClientMessage(playerid,COLOR_YELLOW,str);
- return 1;
- }
- else return SendClientMessage(playerid,COLOR_RED,"Error: You are not recording any NPC.");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement