Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #define NULL 0
- #define HOLDING(%0) ((newkeys & (%0)) == (%0))
- #define PRESSED(%0) (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
- #define RELEASED(%0) (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
- public OnPlayerConnect(playerid) {
- SetPVarInt(playerid, "duration", NULL);
- SetPVarString(playerid, "url", "");
- SetPVarFloat(playerid, "posX", 0.0);
- SetPVarFloat(playerid, "posY", 0.0);
- SetPVarFloat(playerid, "posZ", 0.0);
- SetPVarFloat(playerid, "distance", 50.0);
- SetPVarInt(playerid, "usepos", NULL);
- return 1;
- }
- #if defined _ALS_OnPlayerConnect
- #undef OnPlayerConnect
- #else
- #define _ALS_OnPlayerConnect
- #endif
- #define OnPlayerConnect AudioMS_OnPlayerConnect
- forward AudioMS_OnPlayerConnect(playerid);
- stock StopAudioStreamForPlayerEx(playerid) {
- SetPVarInt(playerid, "duration", NULL);
- SetPVarString(playerid, "url", "");
- SetPVarFloat(playerid, "posX", 0.0);
- SetPVarFloat(playerid, "posY", 0.0);
- SetPVarFloat(playerid, "posZ", 0.0);
- SetPVarFloat(playerid, "distance", 50.0);
- SetPVarInt(playerid, "usepos", NULL);
- StopAudioStreamForPlayer(playerid);
- }
- stock PlayAudioStreamForPlayerEx(playerid, url[], duration, Float:posX = 0.0, Float:posY = 0.0, Float:posZ = 0.0, Float:distance = 50.0, usepos = NULL) {
- if(GetPVarInt(playerid, "duration") == NULL) {
- PlayAudioStreamForPlayer(playerid, url, posX, posY, posZ, distance, usepos);
- SetPVarInt(playerid, "duration", duration);
- SetPVarString(playerid, "url", url);
- SetPVarFloat(playerid, "posX", posX);
- SetPVarFloat(playerid, "posY", posY);
- SetPVarFloat(playerid, "posZ", posZ);
- SetPVarFloat(playerid, "distance", distance);
- SetPVarInt(playerid, "usepos", usepos);
- if(duration != -1) {
- SetTimerEx("StopAudio", duration, NULL, "d", playerid);
- }
- } else if(GetPVarInt(playerid, "duration") == -1) {
- StopAudioStreamForPlayer(playerid);
- PlayAudioStreamForPlayer(playerid, url, posX, posY, posZ, distance, usepos);
- if(duration != -1) {
- new URL[128];
- GetPVarString(playerid, "url", URL, sizeof(URL));
- SetTimerEx("SetNextStream", duration, NULL, "dsdffffd", playerid, URL, GetPVarInt(playerid, "duration"), GetPVarFloat(playerid, "posX"), GetPVarFloat(playerid, "posY"), GetPVarFloat(playerid, "posZ"), GetPVarFloat(playerid, "distance"), GetPVarInt(playerid, "usepos"));
- }
- } else {
- StopAudioStreamForPlayer(playerid);
- PlayAudioStreamForPlayer(playerid, url, posX, posY, posZ, distance, usepos);
- if(duration != -1) {
- new URL[128];
- GetPVarString(playerid, "url", URL, sizeof(URL));
- SetTimerEx("SetNextStream", duration, NULL, "dsdffffd", playerid, URL, GetPVarInt(playerid, "duration"), GetPVarFloat(playerid, "posX"), GetPVarFloat(playerid, "posY"), GetPVarFloat(playerid, "posZ"), GetPVarFloat(playerid, "distance"), GetPVarInt(playerid, "usepos"));
- }
- }
- }
- forward StopAudio(playerid);
- public StopAudio(playerid) {
- StopAudioStreamForPlayerEx(playerid);
- }
- forward SetNextStream(playerid, url[], duration, Float:posX, Float:posY, Float:posZ, Float:distance, usepos);
- public SetNextStream(playerid, url[], duration, Float:posX, Float:posY, Float:posZ, Float:distance, usepos) {
- StopAudioStreamForPlayer(playerid);
- new URL[128];
- format(URL, sizeof(URL), url);
- PlayAudioStreamForPlayer(playerid, URL, Float:posX, Float:posY, Float:posZ, Float:distance, usepos);
- SetPVarInt(playerid, "duration", duration);
- SetPVarString(playerid, "url", URL);
- SetPVarFloat(playerid, "posX", posX);
- SetPVarFloat(playerid, "posY", posY);
- SetPVarFloat(playerid, "posZ", posZ);
- SetPVarFloat(playerid, "distance", distance);
- SetPVarInt(playerid, "usepos", usepos);
- if(duration != -1) {
- SetTimerEx("StopAudio", duration, 0, "d", playerid);
- }
- return true;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) {
- if(IsPlayerInAnyVehicle(playerid)) {
- if(PRESSED(KEY_CROUCH)) {
- PlayAudioStreamForPlayerEx(playerid, "http://alldev.eu/html/mp3/sound_011.wav", 3766);
- StopAudio(playerid);
- } else if(HOLDING(KEY_CROUCH)) {
- PlayAudioStreamForPlayerEx(playerid, "http://alldev.eu/html/mp3/sound_012.wav", 286);
- } else if(RELEASED(KEY_CROUCH)) {
- StopAudio(playerid);
- }
- } else StopAudio(playerid);
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement