Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ***********************************************************************************************************
- FilterScript created by: IlanZ
- Skype: ilan.silva11
- (Do not take the credits)
- ***********************************************************************************************************
- */
- #include <a_samp>
- #include <zcmd>
- #define MAX_MEDKITS (10)
- #define DURABILITY_MEDKIT (10)
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" FilterScript MedKit 1.0v Uploaded. By: IlanZ");
- print("--------------------------------------\n");
- SetTimer("MedKit", 1000, true);
- return 1;
- }
- enum MedKitEnum
- {
- mID,
- mOwner[MAX_PLAYER_NAME],
- Float:mX,
- Float:mY,
- Float:mZ,
- mDurability, // default: 10
- mObjects[2],
- bool:mActive
- }
- new MedKitData[MAX_MEDKITS][MedKitEnum];
- new bool:MedKitZ[MAX_PLAYERS], MedKitZID[MAX_PLAYERS];
- public OnPlayerConnect(playerid)
- {
- SpawnPlayer(playerid);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- DestroyMedKit(MedKitZID[playerid]);
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(newkeys == KEY_SECONDARY_ATTACK)
- {
- cmd_infomedkit(playerid);
- }
- return 1;
- }
- forward MedKit();
- public MedKit()
- {
- for(new i, z = GetPlayerPoolSize(); i <= z; ++i)
- {
- DetectMedKit(i);
- }
- return 1;
- }
- DetectMedKit(playerid)
- {
- new Float:Health, Float:Armour;
- GetPlayerHealth(playerid, Health);
- GetPlayerArmour(playerid, Armour);
- for(new i; i < MAX_MEDKITS; i++)
- {
- if(IsPlayerInRangeOfPoint(playerid, 1.0, MedKitData[i][mX], MedKitData[i][mY], MedKitData[i][mZ]) && MedKitData[i][mActive])
- {
- if(Health >= 100 && Armour >= 100) continue;
- else if(Health < 100)
- {
- SetPlayerHealth(playerid, (Health+7));
- PlayerPlaySound(playerid, 5202, 0.0, 0.0, 0.0);
- MedKitData[i][mDurability]--;
- }
- else if(Health >= 100)
- {
- SetPlayerArmour(playerid, (Armour+7));
- PlayerPlaySound(playerid, 5202, 0.0, 0.0, 0.0);
- MedKitData[i][mDurability]--;
- }
- if(MedKitData[i][mDurability] == 0)
- {
- DestroyMedKit(MedKitData[i][mID]);
- MedKitZ[playerid] = false;
- PlayerPlaySound(playerid, 6402, 0.0, 0.0, 0.0);
- SendClientMessage(playerid, -1, "Medkit broke!");
- }
- }
- }
- return 1;
- }
- CMD:medkit(playerid)
- {
- new Float:X, Float:Y, Float:Z, medkitid;
- if(MedKitZ[playerid])
- return SendClientMessage(playerid, -1, "You can only create a medkit");
- if(GetTotalMedKits() > MAX_MEDKITS)
- return SendClientMessage(playerid, -1, "You can not create now, you have reached the limit");
- GetPlayerPos(playerid,X,Y,Z);
- MedKitData[medkitid][mID] = playerid;
- medkitid = MedKitData[medkitid][mID];
- MedKitData[medkitid][mActive] = true;
- MedKitData[medkitid][mX] = X;
- MedKitData[medkitid][mY] = Y;
- MedKitData[medkitid][mZ] = Z;
- MedKitData[medkitid][mDurability] = DURABILITY_MEDKIT; // default
- MedKitData[medkitid][mObjects][0] = CreateObject(19605, X, Y, Z-2.0, 0, 0, 0);
- MedKitData[medkitid][mObjects][1] = CreatePickup(1240, 1, X, Y, Z);
- MedKitZ[playerid] = true;
- MedKitZID[playerid] = medkitid;
- strcat(MedKitData[medkitid][mOwner], PlayerName(playerid), MAX_PLAYER_NAME);
- SendClientMessage(playerid, -1, "Medkit created");
- return 1;
- }
- CMD:infomedkit(playerid)
- {
- for(new i; i < MAX_MEDKITS; i++)
- {
- if(IsPlayerInRangeOfPoint(playerid, 1.0, MedKitData[i][mX], MedKitData[i][mY], MedKitData[i][mZ]) && MedKitData[i][mActive])
- {
- new str[138];
- format(str, sizeof(str), "Medkit ID: %d\nMedKit X: %.2f\nMedKit Y: %.2f\nMedKit Z: %.2f\nMedKit Durability: (%d/10)\nMedKit Owner: %s",
- MedKitData[i][mID],
- MedKitData[i][mX],
- MedKitData[i][mY],
- MedKitData[i][mZ],
- MedKitData[i][mDurability],
- MedKitData[i][mOwner]);
- ShowPlayerDialog(playerid, 666, DIALOG_STYLE_MSGBOX, "MedKit Information", str, "Exit", "");
- }
- }
- return 1;
- }
- CMD:destroymedkit(playerid)
- {
- DestroyMedKit(playerid);
- MedKitZ[playerid] = false;
- SendClientMessage(playerid, -1, "You've destroyed your medkit");
- return 1;
- }
- DestroyMedKit(medkitid)
- {
- MedKitData[medkitid][mID] = -1;
- MedKitData[medkitid][mActive] = false;
- MedKitData[medkitid][mOwner][0] = EOS;
- DestroyObject(MedKitData[medkitid][mObjects][0]);
- DestroyPickup(MedKitData[medkitid][mObjects][1]);
- return 1;
- }
- GetTotalMedKits()
- {
- new total;
- for(new i; i < MAX_MEDKITS; i++)
- {
- if(MedKitData[i][mActive]) total++;
- }
- return total;
- }
- PlayerName(playerid)
- {
- new nome[24];
- GetPlayerName(playerid, nome, sizeof(nome));
- return nome;
- }
Advertisement
Add Comment
Please, Sign In to add comment