Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* FEITO - TRADUZIDO POR PEDRO_FELIPE - PEDRO_TILAMBUCU
- CREDITOS : LEO_FELIPE, A.K.A Jason , FALLOUTS (Sistema de Batidas)
- Agradecimentos: A todos que me ajudaram no forum da SAMP www.sa-mp.com/forum
- FS - SISTEMA DE CINTO DE SEGURANÇA E BATIDAS
- */
- #include <a_samp>
- #include <a_players>
- #define MAX_STRING 255
- #define COLOR_WHITE 0xFFFFFFAA
- #define COLOR_PURPLE 0xC2A2DAAA
- #define COLOR_LIGHTRED 0xFF6347AA
- #define COLOR_GRAD2 0xBFC0C2FF
- #define COLOR_GREY 0xAFAFAFAA
- forward ProxDetector(Float:radi, playerid, str[],col1,col2,col3,col4,col5);
- forward OnPlayerUpdate(playerid);
- new cinto[MAX_PLAYERS];
- new gPlayerLogged[MAX_PLAYERS];
- new Float:CarHealth[MAX_PLAYERS];
- public OnFilterScriptInit()
- {
- }
- public OnFilterScriptExit()
- {
- print(" Cinto de Seguranca "); // Não tirar
- }
- public OnPlayerConnect(playerid)
- {
- gPlayerLogged[playerid] = 0;
- cinto[playerid] = 0;
- return 1;
- }
- strtok(const string[], &index)
- {
- new length = strlen(string);
- while ((index < length) && (string[index] <= ' '))
- {
- index++;
- }
- new offset = index;
- new result[20];
- while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
- {
- result[index - offset] = string[index];
- index++;
- }
- result[index - offset] = EOS;
- return result;
- }
- public ProxDetector(Float:radi, playerid, str[],col1,col2,col3,col4,col5)
- {
- if(IsPlayerConnected(playerid))
- {
- new Float:posx, Float:posy, Float:posz;
- new Float:oldposx, Float:oldposy, Float:oldposz;
- new Float:tempposx, Float:tempposy, Float:tempposz;
- GetPlayerPos(playerid, oldposx, oldposy, oldposz);
- //radi = 2.0; //Trigger Radius
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- GetPlayerPos(i, posx, posy, posz);
- tempposx = (oldposx -posx);
- tempposy = (oldposy -posy);
- tempposz = (oldposz -posz);
- //printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
- if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
- {
- SendClientMessage(i, col1, str);
- }
- else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
- {
- SendClientMessage(i, col2, str);
- }
- else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
- {
- SendClientMessage(i, col3, str);
- }
- else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
- {
- SendClientMessage(i, col4, str);
- }
- else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
- {
- SendClientMessage(i, col5, str);
- }
- }
- }
- }//not connected
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new string[256];
- new sendername[MAX_PLAYER_NAME];
- new cmd[256];
- new idx;
- cmd = strtok(cmdtext, idx);
- if(strcmp(cmd, "/cintoseg", true) == 0)
- {
- if(IsPlayerConnected(playerid))
- {
- GetPlayerName(playerid, sendername, sizeof(sendername));
- new length = strlen(cmdtext);
- while ((idx < length) && (cmdtext[idx] <= ' '))
- {
- idx++;
- }
- new offset = idx;
- new result[64];
- while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
- {
- result[idx - offset] = cmdtext[idx];
- idx++;
- }
- result[idx - offset] = EOS;
- if(!strlen(result) && IsPlayerInAnyVehicle(playerid) == 0)
- { //line 124
- SendClientMessage(playerid, COLOR_GRAD2, "Você não está em um veiculo");
- return 1;
- }
- if(IsPlayerInAnyVehicle(playerid) == 1 && cinto[playerid] == 0)
- {
- cinto[playerid] = 1;
- SendClientMessage(playerid, COLOR_WHITE, "Você está com cinto , use (/cintoseg) para tirar o cinto.");
- format(string, sizeof(string), "* %s Colocou o cinto de seguranca.", sendername);
- }
- else if(IsPlayerInAnyVehicle(playerid) == 1 && cinto[playerid] == 1)
- {
- cinto[playerid] = 0;
- SendClientMessage(playerid, COLOR_WHITE, "Você tirou seu cinto");
- format(string, sizeof(string), "* %s tirou o cinto de segurança.", sendername);
- TogglePlayerControllable(playerid, 1)
- }
- ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
- printf("%s", string);
- }
- return 1; }
- if (strcmp("/scintoseg", cmdtext, true, 10) == 0)
- {
- SendClientMessage(playerid,COLOR_GREY,"*** Para você colocar/tirar o cinto de segurança , Use /cintoseg. ***");
- SendClientMessage(playerid,COLOR_GREY,"*** Não pule do veiculo com cinto de segurança ou poderá MORRER ENFORCADO! ***");
- SendClientMessage(playerid,COLOR_GREY,"*** Evite andar sem cinto de segurança. Valorize a sua vida ! ***");
- }
- return 0;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- SendClientMessage(playerid, COLOR_LIGHTRED, "Para a sua segurança , ultilize o cinto de seguranca (/cintoseg).");
- SendClientMessage(playerid, COLOR_LIGHTRED, "Não pule do veiculo com cinto de segurança , Poderá se enforcar !")
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid){
- if(cinto[playerid] == 1){
- SendClientMessage(playerid, COLOR_WHITE, "Você pulou do carro com cinto de segurança");
- GameTextForPlayer(playerid, " ~r~E se enforcou com o cinto!", 5000, 3)
- SetPlayerHealth(playerid,0);
- GivePlayerMoney(playerid,-1000);
- }
- return 1;
- }
- // if (IsPlayerInAnyVehicle(playerid) == 1 && cinto[playerid] == 1)
- // cinto[playerid] = 0;
- public OnPlayerUpdate(playerid)
- {
- if(IsPlayerInAnyVehicle(playerid) == 1 && cinto[playerid] == 0)
- {
- new Float:TempCarHealth;
- GetVehicleHealth(GetPlayerVehicleID(playerid), TempCarHealth);
- new Float:Difference = floatsub(CarHealth[playerid], TempCarHealth);
- if((floatcmp(CarHealth[playerid], TempCarHealth) == 1) && (floatcmp(Difference,100.0) == 1))
- {
- Difference = floatdiv(Difference, 10.0);
- new Float:OldHealth;
- GetPlayerHealth(playerid, OldHealth);
- SetPlayerHealth(playerid, floatsub(OldHealth, Difference));
- }
- CarHealth[playerid] = TempCarHealth;
- }
- else
- {
- CarHealth[playerid] = 0.0;
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement