Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ***********************************************************************************************************
- FilterScript criado por: IlanZ
- Skype: ilan.silva11
- (Não tire os créditos)
- ***********************************************************************************************************
- */
- #include <a_samp>
- #include <zcmd>
- #define MAX_MEDKITS (10)
- #define DURABILIDADE_MEDKIT (10)
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" FilterScript MedKit 1.0v Carregado. By: IlanZ");
- print("--------------------------------------\n");
- SetTimer("MedKit", 1000, true);
- print("Iniciado");
- return 1;
- }
- enum MedKitEnum
- {
- mID,
- mDono[MAX_PLAYER_NAME],
- Float:mX,
- Float:mY,
- Float:mZ,
- mDurabilidade, // default: 10
- mObjetos[2],
- bool:mAtivo
- };
- new MedKitDados[MAX_MEDKITS][MedKitEnum];
- new bool:MedKitZ[MAX_PLAYERS], MedKitZID[MAX_PLAYERS];
- public OnPlayerConnect(playerid)
- {
- SpawnPlayer(playerid);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- DestruirMedKit(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; i < MAX_PLAYERS; ++i)
- {
- DetectarMedKit(i);
- }
- return 1;
- }
- DetectarMedKit(playerid)
- {
- new Float:Vida, Float:Colete;
- GetPlayerHealth(playerid, Vida);
- GetPlayerArmour(playerid, Colete);
- for(new i; i < MAX_MEDKITS; i++)
- {
- if(IsPlayerInRangeOfPoint(playerid, 1.0, MedKitDados[i][mX], MedKitDados[i][mY], MedKitDados[i][mZ]) && MedKitDados[i][mAtivo])
- {
- if(Vida >= 100 && Colete >= 100) continue;
- else if(Vida < 100)
- {
- SetPlayerHealth(playerid, (Vida+7));
- PlayerPlaySound(playerid, 5202, 0.0, 0.0, 0.0);
- MedKitDados[i][mDurabilidade]--;
- }
- else if(Vida >= 100)
- {
- SetPlayerArmour(playerid, (Colete+7));
- PlayerPlaySound(playerid, 5202, 0.0, 0.0, 0.0);
- MedKitDados[i][mDurabilidade]--;
- }
- if(MedKitDados[i][mDurabilidade] == 0)
- {
- DestruirMedKit(MedKitDados[i][mID]);
- MedKitZ[playerid] = false;
- PlayerPlaySound(playerid, 6402, 0.0, 0.0, 0.0);
- SendClientMessage(playerid, -1, "Medkit quebrou!");
- }
- }
- }
- return 1;
- }
- CMD:medkit(playerid)
- {
- new Float:X, Float:Y, Float:Z, medkitid;
- if(MedKitZ[playerid])
- return SendClientMessage(playerid, -1, "Você so pode criar um medkit");
- if(GetTotalMedKits() > MAX_MEDKITS)
- return SendClientMessage(playerid, -1, "Você não pode criar agora, atingiu o limite");
- GetPlayerPos(playerid,X,Y,Z);
- MedKitDados[medkitid][mID] = playerid;
- medkitid = MedKitDados[medkitid][mID];
- MedKitDados[medkitid][mAtivo] = true;
- MedKitDados[medkitid][mX] = X;
- MedKitDados[medkitid][mY] = Y;
- MedKitDados[medkitid][mZ] = Z;
- MedKitDados[medkitid][mDurabilidade] = DURABILIDADE_MEDKIT; // default
- MedKitDados[medkitid][mObjetos][0] = CreateObject(19605, X, Y, Z-2.0, 0, 0, 0);
- MedKitDados[medkitid][mObjetos][1] = CreatePickup(1240, 1, X, Y, Z);
- MedKitZ[playerid] = true;
- MedKitZID[playerid] = medkitid;
- strcat(MedKitDados[medkitid][mDono], PlayerName(playerid), MAX_PLAYER_NAME);
- SendClientMessage(playerid, -1, "Medkit criado");
- return 1;
- }
- CMD:infomedkit(playerid)
- {
- for(new i; i < MAX_MEDKITS; i++)
- {
- if(IsPlayerInRangeOfPoint(playerid, 1.0, MedKitDados[i][mX], MedKitDados[i][mY], MedKitDados[i][mZ]) && MedKitDados[i][mAtivo])
- {
- new str[138];
- format(str, sizeof(str), "Medkit ID: %d\nMedKit X: %.2f\nMedKit Y: %.2f\nMedKit Z: %.2f\nMedKit durabilidade: (%d/10)\nMedKit dono: %s",
- MedKitDados[i][mID],
- MedKitDados[i][mX],
- MedKitDados[i][mY],
- MedKitDados[i][mZ],
- MedKitDados[i][mDurabilidade],
- MedKitDados[i][mDono]);
- ShowPlayerDialog(playerid, 666, DIALOG_STYLE_MSGBOX, "Informaçoes do MedKit", str, "Sair", "");
- }
- }
- return 1;
- }
- CMD:destruirmedkit(playerid)
- {
- MedKitDados[playerid][mID] = -1;
- MedKitDados[playerid][mAtivo] = false;
- MedKitDados[playerid][mDono][0] = EOS;
- DestroyObject(MedKitDados[playerid][mObjetos][0]);
- DestroyPickup(MedKitDados[playerid][mObjetos][1]);
- MedKitZ[playerid] = false;
- SendClientMessage(playerid, -1, "Você destruiu seu Medkit");
- return 1;
- }
- DestruirMedKit(medkitid)
- {
- MedKitDados[medkitid][mID] = -1;
- MedKitDados[medkitid][mAtivo] = false;
- MedKitDados[medkitid][mDono][0] = EOS;
- DestroyObject(MedKitDados[medkitid][mObjetos][0]);
- DestroyPickup(MedKitDados[medkitid][mObjetos][1]);
- return 1;
- }
- GetTotalMedKits()
- {
- new total;
- for(new i; i < MAX_MEDKITS; i++)
- {
- if(MedKitDados[i][mAtivo]) total++;
- }
- return total;
- }
- PlayerName(playerid)
- {
- new nome[24];
- GetPlayerName(playerid, nome, sizeof(nome));
- return nome;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement