02.05.2010, 23:52
yes. the npc script can handle that by sending a command. i use it for announcing special events, happenings, w/e u call it. that function gets called by a lot of npcs - imo its a very comfortable way once you figured it out, however, i would appreciate a better, more precise way for doing that. :/
NPC script:
2 snippets inside a filterscript: ...it wont harm if theyre not present, coz the npc will recieve "command not found." ^^
edit: you could use the OnPlayerKeyStateChange too, f.ex to trigger functions like arresting, accepting a deal etc. using the KEY_SUBMISSION, KEY_CROUCH etc.
NPC script:
Code:
#define RECORDING "LicenseA" #define RECORDING_TYPE 1 #include <a_npc> new CyclesMin=20; new CyclesMax=40; new CyclesATM=35; new gTimerLicense; public OnRecordingPlaybackEnd() StartRecordingPlayback(RECORDING_TYPE, RECORDING); #if RECORDING_TYPE == 1 public OnNPCEnterVehicle(vehicleid, seatid) StartRecordingPlayback(RECORDING_TYPE, RECORDING); public OnNPCExitVehicle() StopRecordingPlayback(); #else public OnNPCSpawn() StartRecordingPlayback(RECORDING_TYPE, RECORDING); #endif main() { printf("License"); } public OnNPCModeInit() { gTimerLicense=SetTimer("TimerLicense",2000,1); } public OnNPCModeExit() { KillTimer(gTimerLicense); } forward TimerLicense(); public TimerLicense() { CyclesATM++; if(CyclesATM>CyclesMin) { if(CyclesATM>CyclesMax || random(10)<2) { new Amount=10000;//need to calculate a random amount, so the money wont stack up new NPCcmd[32]; format(NPCcmd,sizeof(NPCcmd),"/dt %d",Amount); // thats the "drop treasure" command, it will create a simple money pickup... SendCommand(NPCcmd); new msg[128]; format(msg,128,"/Aq make your license! get less wanted levels for stealing a vehicle!",Amount); SendCommand(msg); format(msg,128,"i got $#mon here, i will drop some!",Amount); //#mon is a quickstring, it will insert your actual money, its processed in the GM... SendChat(msg); CyclesATM=0; } } }
Code:
dcmd_Aq(playerid,params[]) { new Text[128]; if (sscanf(params,"s",Text)) { SendClientMessage(playerid,MSGCOMM_COLOR, "Usage: \"/Aq <Text>\""); return 1; } AddNews(playerid,Text); return 1; } forward AddNews(playerid,Text[]); public AddNews(playerid,Text[]) { // SendClientMessage(playerid,0xffffffff,Text); format(TDTSMessageText,sizeof(TDTSMessageText),"%s%s_",TDTSMessageText,Text); //looks weird, i know :) ShowTDTS(); return 1; }
Code:
. regards ..: babul
