Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Particle Effects
- 18692 fire
- 18697 helidust
- 18731 tear gas
- 18732 large tear gas
- 18675 coke puff
- */
- #define FILTERSCRIPT
- #include <a_samp>
- #include <zcmd>
- #include <sscanf2>
- new Float: speed = 0.5; // by default
- new dragonBorns[512];
- new dragonBorn[MAX_PLAYERS];
- new myShout[MAX_PLAYERS];
- new myCoolDown[MAX_PLAYERS];
- new shoutEffect[MAX_PLAYERS][3];// 0 = disarm, 1 = fire damage, 2 = frost damage
- new fireEffect[MAX_PLAYERS];
- new frostEffect[MAX_PLAYERS];
- new playerWeapon[MAX_PLAYERS];
- new useCoolDown = 0; //default 0 - off
- new timerID;
- new shoutNames[5][30] = {"Unrelenting Force", "Whirlwind Sprint", "Disarm", "Fire Breath", "Frost Breath"};
- new shoutCool[5] = {18, 14, 16, 25, 25};
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" ulfricmalcom");
- print("--------------------------------------\n");
- timerID = SetTimer("OneSecUpdate", 1000, true);
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i)) playerWeapon[i] = GetPlayerWeapon(i);
- /*fireEffect[i] = -1;
- frostEffect[i] = -1;*/
- }
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("Shout unloaded.");
- KillTimer(timerID);
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- //weapon swap checker
- new iCurWeap = GetPlayerWeapon(playerid);
- if(iCurWeap != playerWeapon[playerid])
- {
- if(shoutEffect[playerid][0] > 0)
- {
- if(iCurWeap > 15 || iCurWeap < 43)SetPlayerArmedWeapon(playerid, 0);
- }
- playerWeapon[playerid] = iCurWeap;
- }
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- for(new e = 0; e < 3; e++) shoutEffect[playerid][e] = 0;
- return 1;
- }
- /*CMD:cooldown(playerid, params[])
- {
- new string[128], option[5];
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, " ");
- if(useCoolDown == 0){
- useCoolDown = 1;
- option = "on";
- }else{
- useCoolDown = 0;
- option = "off";
- }
- format(string, 128, "Cool down is now %s.", option);
- SendClientMessageToAll(-1, string);
- return 1;
- }*/
- CMD:dshout(playerid, params[])
- {
- new Float:x, Float:y, Float:z, string[128];
- new shouttype = myShout[playerid];
- GetPlayerHealth(playerid, z);
- if(!dragonBorn[playerid]) return SendClientMessage(playerid, -1, " * You cannot shout, you are not the dragon born!");
- if(z < 0.0000001) return SendClientMessage(playerid, -1, "You can't shout if you are dead.");
- if(useCoolDown == 1 && myCoolDown[playerid] != 0)
- {
- format(string, sizeof(string), "Please wait for %d seconds before shouting again.", myCoolDown[playerid]);
- return SendClientMessage(playerid, -1, string);
- }
- if(IsPlayerInAnyVehicle(playerid))
- {
- GetPlayerPos(playerid, x, y, z);
- CreateExplosion(x, y, z, 2, 10.0);
- SetPlayerHealth(playerid, 0.0);
- return SendClientMessage(playerid, -1, "You shouted in a vehicle, thus creating an awesome explosion.");
- }
- GetPlayerPos(playerid, x, y, z);
- SendShoutSoundToAll(x, y, z, myShout[playerid]);
- SetTimerEx("ApplyShout", 1000, false, "ii", shouttype, playerid);
- if(shouttype == 0) SetPlayerChatBubble(playerid, "FUS RO DAH", -1, 35, 5000);
- else if(shouttype == 1) SetPlayerChatBubble(playerid, "WULD NAH KEST", -1, 35, 5000);
- else if(shouttype == 2) SetPlayerChatBubble(playerid, "ZUN HAL VIIK", -1, 35, 5000);
- else if(shouttype == 3) SetPlayerChatBubble(playerid, "YOL TOOR SHUL", -1, 35, 5000);
- else if(shouttype == 4) SetPlayerChatBubble(playerid, "FO KRAH DIIN", -1, 35, 5000);
- return 1;
- }
- CMD:setshout(playerid, params[])
- {
- new shouttype, string[128];
- if(!dragonBorn[playerid]) return SendClientMessage(playerid, -1, " * You cannot shout, you are not the dragon born!");
- if(sscanf(params, "d", shouttype))
- {
- SendClientMessage(playerid, -1, "Syntax: /setshout [shoutid]");
- SendClientMessage(playerid, -1, "Unrelenting Force(0) Whirlwind Sprint(1) Disarm(2) Fire Breath(3) Frost Breath(4)");
- return 1;
- }
- if(shouttype > 4 || shouttype < 0) return SendClientMessage(playerid, -1, "Invalid ID");
- format(string, 128, "%s >>> %s", shoutNames[myShout[playerid]], shoutNames[shouttype]);
- SendClientMessage(playerid, -1, string);
- myShout[playerid] = shouttype;
- return 1;
- }
- CMD:ldb(playerid, params[]) // non robust all the way to ddb
- {
- LoadDragonBorn();
- return 1;
- }
- CMD:ddisplay(playerid, params[])
- {
- SendClientMessage(playerid, -1, dragonBorns);
- return 1;
- }
- CMD:adb(playerid, params[])
- {
- AddPlayerToDragonBorn(strval(params));
- return 1;
- }
- CMD:ddb(playerid, params[])
- {
- DeletePlayerFromDragonBorn(strval(params));
- return 1;
- }
- forward ApplyShout(shouttype, senderid);
- public ApplyShout(shouttype, senderid)
- {
- new string[128], name[MAX_PLAYER_NAME + 1];
- GetPlayerName(senderid, name, sizeof(name));
- new Float: x, Float:y, Float:z, Float: xEx, Float: yEx;
- GetPlayerPos(senderid, x, y, z);
- GetXYInFrontOfPlayer(senderid, x, y, 5.0);
- GetXYInFrontOfPlayer(senderid, xEx, yEx, 10.0);
- //-------------------------------------------------------------------//
- if(shouttype == 1)
- {
- new Float:angle, Float:xV, Float:yV;
- GetPlayerPos(senderid, x, y, z);
- GetPlayerFacingAngle(senderid, angle);
- xV = (0.65 * floatsin(-angle, degrees));
- yV = (0.65 * floatcos(-angle, degrees));
- SetPlayerVelocity(senderid, xV, yV, 0.2);
- if(useCoolDown == 1) myCoolDown[senderid] += shoutCool[shouttype];
- return 1;
- }
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(IsPlayerInRangeOfPoint(i, 5.0, x, y, z) || IsPlayerInRangeOfPoint(i, 8.0, xEx, yEx, z))
- {
- if(i != senderid)
- {
- if(shouttype == 0)
- {
- new Float: health, bool:inVeh;
- new Float: opX, Float: opY, Float:opZ, Float: xV, Float: yV, Float: fAngle;
- new Float: victimX, Float: victimY;
- GetPlayerPos(senderid, opX, opY, opZ);
- GetPlayerPos(i, victimX, victimY, opZ);
- fAngle = GetFacingPos(victimX, victimY, opX, opY);
- xV = (speed * floatsin(-fAngle, degrees));
- yV = (speed * floatcos(-fAngle, degrees));
- xV *= -1;
- yV *= -1;
- if (IsPlayerInAnyVehicle(i)) inVeh = true;
- GetPlayerHealth(i, health);
- if(inVeh)
- {
- xV *= 0.85;
- yV *= 0.85;
- SetVehicleVelocity(GetPlayerVehicleID(i), xV, yV, 0.5);
- inVeh = false;
- }
- else
- {
- health -= 2.0;
- SetPlayerVelocity(i, xV, yV, 0.3);
- SetPlayerHealth(i, health);
- }
- }
- else if(shouttype == 2)
- {
- new weap = GetPlayerWeapon(senderid);
- shoutEffect[i][0] = 10;
- if(weap > 15 || weap < 43)SetPlayerArmedWeapon(i, 0);
- if(GetPlayerWeapon(i) != 0) GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~r~Disarmed~n~~g~Wait for 10 seconds", 2000, 3);
- else GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~n~~g~Additional 10 seconds added - Disarm", 2000, 3);
- FallFromPlayer(senderid, i);
- }
- else if(shouttype == 3 || shouttype == 4)
- {
- new Float:health;
- if(shouttype == 3)
- {
- GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~r~Fire Effect Added", 2000, 3);
- GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~n~~g~OH lord jesus there is a FiRe!", 2000, 3);
- if(IsPlayerInAnyVehicle(i))
- {
- new Float: px, Float: py, Float: pz;
- GetPlayerPos(i, px, py, pz);
- CreateExplosion(px, py, pz, 7, 20);
- }
- shoutEffect[i][1] = 10;
- }
- else
- {
- GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~b~Frost Effect Added", 2000, 3);
- shoutEffect[i][2] = 10;
- }
- new slot = GetNextSlot(i);
- if(slot == -1) SendClientMessage(i, -1, "No Object will be attached.");
- else
- {
- if(shouttype == 3 && fireEffect[i] == -1)
- {
- SetPlayerAttachedObject(i, slot, 18692, 1, 0.0, 0.0, -1.613);
- fireEffect[i] = slot;
- }
- else if(shouttype == 4 && frostEffect[i] == -1)
- {
- SetPlayerAttachedObject(i, slot, 18675, 1, -1.04, 0.18, -1.991);
- frostEffect[i] = slot;
- }
- }
- GetPlayerHealth(i, health);
- SetPlayerHealth(i, (health - 10.0));
- FallFromPlayer(senderid, i);
- }
- //---------------------------------------------//
- if(shouttype != 1)
- {
- format(string, sizeof(string), "%s has applied %s on you.", name, shoutNames[shouttype]);
- SendClientMessage(i, -1, string);
- }
- else SendClientMessage(i, -1, "Invalid shout ID passed.");//close if statement
- }// not the command sender
- }// range check
- }//online check
- }//close loop
- if(useCoolDown == 1)
- {
- if(shouttype == 0 || shouttype == 2 || shouttype == 3 || shouttype == 4) myCoolDown[senderid] += shoutCool[shouttype];
- }
- return 1;
- }//close function
- forward SendShoutSoundToAll(Float:x, Float:y, Float:z, shouttype);
- public SendShoutSoundToAll(Float:x, Float:y, Float:z, shouttype)
- {
- if(shouttype == 0 || shouttype == 1 || shouttype == 2 || shouttype == 3 || shouttype == 4)
- {
- for(new i = 0; i< MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(IsPlayerInRangeOfPoint(i, 70.0, x, y, z))
- {
- if(shouttype == 0) PlayAudioStreamForPlayer(i, "http://images.wikia.com/elderscrolls/images/8/81/UnrelentingForce.ogg", x, y, z, 70.0, 1);
- else if(shouttype == 1) PlayAudioStreamForPlayer(i, "http://images.wikia.com/elderscrolls/images/4/4b/Whirlwindsprint.ogg", x, y, z, 70.0, 1);
- else if(shouttype == 2) PlayAudioStreamForPlayer(i, "http://images.wikia.com/elderscrolls/images/5/5c/Disarm.ogg", x, y, z, 70.0, 1);
- else if(shouttype == 3) PlayAudioStreamForPlayer(i, "http://images.wikia.com/elderscrolls/images/f/f5/FireBreath.ogg", x, y, z, 70.0, 1);
- else if(shouttype == 4) PlayAudioStreamForPlayer(i, "http://images.wikia.com/elderscrolls/images/a/aa/FrostBreath.ogg", x, y, z, 70.0, 1);
- }//range check
- }//online checker
- }//loop
- }
- else{
- new string[128];
- format(string, 128, "Invalid ID(%d) passed to X:%f, Y:%f, Z:%f", shouttype, x, y, z);
- SendClientMessageToAll(-1, string);
- }
- }
- forward OneSecUpdate();
- public OneSecUpdate()
- {
- new Float:health;
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(myCoolDown[i] != 0 && useCoolDown == 1) myCoolDown[i] -= 1; //shout cooldown
- for(new e = 0; e < 3; e++) if(shoutEffect[i][e] != 0) shoutEffect[i][e] -= 1; //effect cooldown
- if(shoutEffect[i][1] == 0 && fireEffect[i] >= 0)
- {
- RemovePlayerAttachedObject(i, fireEffect[i]);
- fireEffect[i] = -1;
- }
- else if(shoutEffect[i][2] == 0 && frostEffect[i] >= 0)
- {
- RemovePlayerAttachedObject(i, frostEffect[i]);
- frostEffect[i] = -1;
- }
- if(shoutEffect[i][1] != 0 || shoutEffect[i][2] != 0)
- {
- GetPlayerHealth(i, health);
- SetPlayerHealth(i, (health - 5.0));
- }
- //printf("Player ID: %d, Fire Object: %d, Frost Object: %d", i, fireEffect[i], frostEffect[i]);
- }//online checker
- }//close loop
- }
- forward Float: GetFacingPos(Float: fromX, Float: fromY, Float: x, Float: y);
- Float: GetFacingPos(Float: fromX, Float: fromY, Float:x, Float:y)//http://forum.sa-mp.com/showthread.php?t=38965&page=338
- {
- new Float:angle;
- new Float:misc = 5.0;
- angle = 180.0-atan2(fromX-x,fromY-y);
- angle += misc;
- misc *= -1;
- angle += misc;
- return angle;
- }
- GetNextSlot(playerid)
- {
- for(new i = 0; i < MAX_PLAYER_ATTACHED_OBJECTS; i++)
- {
- if(!IsPlayerAttachedObjectSlotUsed(playerid, i)) return i;
- }
- return -1;
- }
- FallFromPlayer(playerid, victim)
- {
- new Float: pX, Float: pY, Float: z, Float: vicX, Float: vicY, Float: angle;
- GetPlayerPos(playerid, pX, pY, z);
- GetPlayerPos(victim, vicX, vicY, z);
- angle = GetFacingPos(vicX, vicY, pX, pY);
- SetPlayerFacingAngle(victim, angle);
- ApplyAnimation(victim, "PED", "BIKE_fallR", 4.0, 0, 1, 1, 0, 0);
- }
- GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
- {
- // Credit: Y_Less
- new Float:a;
- GetPlayerPos(playerid, x, y, a);
- GetPlayerFacingAngle(playerid, a);
- if (GetPlayerVehicleID(playerid)) {
- GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
- }
- x += (distance * floatsin(-a, degrees));
- y += (distance * floatcos(-a, degrees));
- }
- LoadDragonBorn()
- {
- new name[MAX_PLAYER_NAME + 1];
- new File: file = fopen("DragonBorns.txt", io_read);
- if (!fexist("DragonBorns.txt")) return print(">>>>>.DragonBorn.txt doesn not exits! make one in the folder.<<<<<<");
- else{
- fread(file, dragonBorns);
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- GetPlayerName(i, name, sizeof(name));
- if(strfind(dragonBorns, name, false) != -1) dragonBorn[i] = 1;
- else dragonBorn[i] = 0;
- }
- }
- }
- fclose(file);
- return 1;
- }
- DeletePlayerFromDragonBorn(playerid)
- {
- new name[MAX_PLAYER_NAME + 1];
- new File: file = fopen("DragonBorns.txt", io_write);
- if (!fexist("DragonBorns.txt")) return print(">>>>>.DragonBorn.txt doesn not exits! make one in the folder.<<<<<<");
- else{
- GetPlayerName(playerid, name, sizeof(name));
- if(strfind(dragonBorns, name, false) == -1) return 1;
- new spos = strfind(dragonBorns, name, false);
- new epos = spos + strlen(name);
- epos += 1;
- strdel(dragonBorns, spos, epos);
- fwrite(file, dragonBorns);
- }
- fclose(file);
- return 1;
- }
- AddPlayerToDragonBorn(playerid)
- {
- new name[MAX_PLAYER_NAME + 1], string[30];
- new File: file = fopen("DragonBorns.txt", io_append);
- if (!fexist("DragonBorns.txt")) return print(">>>>>.DragonBorn.txt doesn not exits! make one in the folder.<<<<<<");
- if(strfind(dragonBorns, name, false) != -1) return 1;
- GetPlayerName(playerid, name, sizeof(name));
- format(string, sizeof(string), "%s,", name);
- strcat(dragonBorns, string, sizeof(dragonBorns));
- fwrite(file, string);
- fclose(file);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment