Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_npc>
- main() {}
- new bool:updateStatus = false, MAX_PLAYERS_ = MAX_PLAYERS, bool:usedCommand = false, bool:stopped = false;
- public OnRecordingPlaybackEnd() StartRecordingPlayback(1,"bus");
- public OnNPCEnterVehicle(vehicleid, seatid)
- {
- StartRecordingPlayback(1,"bus");
- stopped = false;
- }
- public OnNPCExitVehicle() StopRecordingPlayback();
- public OnClientMessage(color, text[]) if(usedCommand && IsNumeric(text) && strlen(text) > 0 && strlen(text) <= 3) MAX_PLAYERS_ = strval(text), usedCommand = false;
- public OnNPCModeInit() SetTimer("BusUpdate",1500,1);
- forward BusUpdate();
- public BusUpdate()
- {
- if((updateStatus = !updateStatus))
- {
- SendCommand("/maxplayers");
- usedCommand = true;
- }
- else
- {
- new bool:hasReason = SearchForSomeoneInFrontOfMe();
- if(hasReason && !stopped)
- {
- PauseRecordingPlayback();
- stopped = true;
- }
- else if(!hasReason && stopped)
- {
- ResumeRecordingPlayback();
- stopped = false;
- }
- }
- return 1;
- }
- stock GetXYInFrontOfMe(Float:distance, &Float:x, &Float:y)
- { // by Kye
- new Float:z, Float:angle;
- GetMyPos(x,y,z);
- GetMyFacingAngle(angle);
- x += (distance * floatsin(-angle, degrees));
- y += (distance * floatcos(-angle, degrees));
- }
- stock IsNumeric(const string[])
- {
- for(new i = string[0] == '-' ? 1 : 0, j = strlen(string); i < j; i++) if(string[i] < '0' || string[i] > '9') return 0;
- return 1;
- }
- forward bool:SearchForSomeoneInFrontOfMe();
- stock bool:SearchForSomeoneInFrontOfMe()
- {
- new Float:p[3], player[MAX_PLAYERS], players = 0;
- GetMyPos(p[0],p[1],p[2]);
- GetXYInFrontOfMe(17.5,p[0],p[1]);
- for(new i = 0; i < MAX_PLAYERS_; i++) if(IsPlayerConnected(i) && IsPlayerStreamedIn(i)) if((GetPlayerState(i) == PLAYER_STATE_DRIVER || GetPlayerState(i) == PLAYER_STATE_ONFOOT) && IsPlayerInRangeOfPoint(i,11.0,p[0],p[1],p[2])) player[players++] = i;
- if(players > 0 && !stopped)
- {
- new string[128];
- if(players == 1)
- {
- GetPlayerName(player[0],string,MAX_PLAYER_NAME);
- else switch(random(2))
- {
- case 0: format(string,sizeof(string),"%s MOVE!",string);
- case 1: format(string,sizeof(string),"%s, I need to drive there!",string);
- }
- }
- else if(players > 1)
- {
- switch(random(2))
- {
- case 0: format(string,sizeof(string),"Get out of my way.");
- case 1: format(string,sizeof(string),"%d of you, get away!",players);
- }
- }
- format(string,sizeof(string),"/italk2all %s",string);
- SendCommand(string);
- }
- return players > 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement