10.08.2012, 00:28
Olб galera, estou com um [FS] aqui, sу que preciso de ajuda.
Ele funciona corretamente sу que quero melhorar ele, mais nгo sei como.
Oque eu quero й, quando digitar /portamalas vai abrir o porta malas, quando forem pega as arma o porta malas fecha.
Igual /portamalas(abre)
/portamalas colocararma(abre, depois de um tempo fecha)
/portamalas pegararma(abre depois de um tempo fecha)
Comandos: - Porta-Malas -
Comandos:
/portamalas
/portamalas info
/portamalas colocararma
/portamalas pegararma
/portamalas colocarcolete
/portamalas pegarcolete
[FS]:
Ele funciona corretamente sу que quero melhorar ele, mais nгo sei como.
Oque eu quero й, quando digitar /portamalas vai abrir o porta malas, quando forem pega as arma o porta malas fecha.
Igual /portamalas(abre)
/portamalas colocararma(abre, depois de um tempo fecha)
/portamalas pegararma(abre depois de um tempo fecha)
Comandos: - Porta-Malas -
Comandos:
/portamalas
/portamalas info
/portamalas colocararma
/portamalas pegararma
/portamalas colocarcolete
/portamalas pegarcolete
[FS]:
Код:
#include <a_samp> #if defined MAX_VEHICLES #undef MAX_VEHICLES #define MAX_VEHICLES 700 //change to your vehicles number #endif #if defined MAX_PLAYERS #undef MAX_PLAYERS #define MAX_PLAYERS 50 //change to your player slot number #endif #define GREY 0xAFAFAFAA #define WHITE 0xFFFFFFAA #define CHAT1 0xF9B7FFAA #define LIGHTBLUE 0xA9C4E4FF #define MAX_TRUNK_SLOTS 5 // trunk slots new vehTrunkCounter[MAX_VEHICLES] = 1; new vehTrunk[MAX_VEHICLES][MAX_TRUNK_SLOTS]; new vehTrunkAmmo[MAX_VEHICLES][MAX_TRUNK_SLOTS]; new Float:vehTrunkArmour[MAX_VEHICLES]; new BigEar[MAX_PLAYERS]; new ScriptWeaponsUpdated[MAX_PLAYERS]; new ScriptWeapons[MAX_PLAYERS][13]; public OnPlayerCommandText(playerid, cmdtext[]) { new cmd[128], idx, string[128]; cmd = strtok(cmdtext, idx); if(!strcmp(cmd, "/portamalas", true)) { new x_nr[64], pname[20]; x_nr = strtok(cmdtext, idx); GetPlayerName(playerid, pname, sizeof(pname)); if(!strlen(x_nr)) { SendClientMessage(playerid, WHITE, "DICA: /portamalas [name]"); SendClientMessage(playerid, WHITE, "nomes Disponнvel: info, colocararma, pegararma, colocarcolete, pegarcolete"); /*if(IsPlayerAdmin(playerid)) { SendClientMessage(playerid, WHITE, "Vocк pode revistar '/portamalas frisk' como um administrador."); }*/ return 1; } if(strcmp(x_nr,"info",true) == 0) { new counter = 0; new result; for(new i; i != MAX_VEHICLES; i++) { new dist = CheckPlayerDistanceToVehicle(3.5, playerid, i); if(dist) { result = i; counter++; } } switch(counter) { case 0: { SendClientMessage(playerid, GREY, "Nenhum carro com o porta malas perto de vocк"); } case 1: { if(IsPlayerInAnyVehicle(playerid)) { SendClientMessage(playerid, GREY, " Vocк nгo pode abrir o porta malas, enquanto vocк estб no carro"); return 1; } /*if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 440 || GetVehicleModel(GetPlayerVehicleID(playerid)) != 456 || GetVehicleModel(GetPlayerVehicleID(playerid)) != 498) { SendClientMessage(playerid, GREY, " This vehicle doesn't have the trunk !"); return 1; }*/ SendClientMessage(playerid, LIGHTBLUE, "|_______ Porta-Malas _______|"); for(new slot = 1; slot != MAX_TRUNK_SLOTS; slot++) { new gunname[100]; if(vehTrunk[result][slot] != 0) { GetWeaponName(vehTrunk[result][slot], gunname, sizeof(gunname)); format(string, sizeof(string), "| Slot %i: %s (Muniзгo: %i)", slot, gunname, vehTrunkAmmo[result][slot]); SendClientMessage(playerid, WHITE, string); } else { format(string, sizeof(string), "| Slot %i: Livre (Muniзгo: N/A)", slot); SendClientMessage(playerid, WHITE, string); } } format(string, sizeof(string), "| Colete: %f%", vehTrunkArmour[result]); SendClientMessage(playerid, WHITE, string); format(string, sizeof(string), "* %s abre o porta-malas e checa o que hб dentro.", pname); ProxDetector(30.0, playerid, string, CHAT1, CHAT1, CHAT1, CHAT1, CHAT1); return 1; } default: { SendClientMessage(playerid, GREY, "Foi encontrado mais de um carro na бrea."); return 1; } } return 1; } else if(!strcmp(x_nr,"colocararma",true)) { new counter = 0; new result; for(new i; i != MAX_VEHICLES; i++) { new dist = CheckPlayerDistanceToVehicle(3.5, playerid, i); if(dist) { result = i; counter++; } } switch(counter) { case 0: { SendClientMessage(playerid, GREY, "Nenhum carro com o Porta-Malas perto de vocк"); } case 1: { if(vehTrunkCounter[result] != (MAX_TRUNK_SLOTS-1)) { if(IsPlayerInAnyVehicle(playerid)) { SendClientMessage(playerid, GREY, "Vocк nгo pode abrir o Porta-Malas, enquanto vocк estб no carro"); return 1; } /*if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 440 || GetVehicleModel(GetPlayerVehicleID(playerid)) != 456 || GetVehicleModel(GetPlayerVehicleID(playerid)) != 498) { SendClientMessage(playerid, GREY, " This vehicle doesn't have the trunk !"); return 1; }*/ new buffer[512]; new gunname[100]; new gunID = GetPlayerWeapon(playerid); new gunAmmo = GetPlayerAmmo(playerid); if(gunID != 0 && gunAmmo != 0) { GetWeaponName(gunID, gunname, sizeof(gunname)); vehTrunkCounter[result]++; vehTrunk[result][vehTrunkCounter[result]] = gunID; vehTrunkAmmo[result][vehTrunkCounter[result]] = gunAmmo; format(buffer, sizeof(buffer), "Vocк colocou um(a) %s (Muniзгo: %i) no porta-malas do carro.", gunname, gunAmmo); SendClientMessage(playerid, WHITE, buffer); RemovePlayerWeapon(playerid, gunID); format(string, sizeof(string), "* %s Abre o porta-mala do carro e coloca uma arma lб.", pname); ProxDetector(30.0, playerid, string, CHAT1, CHAT1, CHAT1, CHAT1, CHAT1); return 1; } } else { SendClientMessage(playerid, GREY, "porta-mala do carro estб cheio"); return 1; } } default: { SendClientMessage(playerid, GREY, "Foi encontrado mais de um carro na Яrea."); return 1; } } return 1; } else if(strcmp(x_nr,"pegararma",true) == 0) { new counter = 0; new result; for(new i; i != MAX_VEHICLES; i++) { new dist = CheckPlayerDistanceToVehicle(3.5, playerid, i); if(dist) { result = i; counter++; } } switch(counter) { case 0: { SendClientMessage(playerid, GREY, "Nenhum carro com porta-malas perto de vocк!"); return 1; } case 1: { if(IsPlayerInAnyVehicle(playerid)) { SendClientMessage(playerid, GREY, " Vocк nгo pode abrir o porta-malas de dentro do carro."); return 1; } /*if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 440 || GetVehicleModel(GetPlayerVehicleID(playerid)) != 456 || GetVehicleModel(GetPlayerVehicleID(playerid)) != 498) { SendClientMessage(playerid, GREY, " This vehicle doesn't have the trunk !"); return 1; }*/ if(vehTrunkCounter[result] != 0) { new buffer[512]; new gunName[100]; SafeGivePlayerWeapon(playerid, vehTrunk[result][vehTrunkCounter[result]], vehTrunkAmmo[result][vehTrunkCounter[result]]); GetWeaponName(vehTrunk[result][vehTrunkCounter[result]], gunName, sizeof(gunName)); format(buffer, sizeof(buffer), "Voce retirou um(a) %s (Ammo: %i) do veнculo.", gunName, vehTrunkAmmo[result][vehTrunkCounter[result]]); SendClientMessage(playerid, WHITE, buffer); vehTrunk[result][vehTrunkCounter[result]] = '\0'; vehTrunkAmmo[result][vehTrunkCounter[result]] = '\0'; vehTrunkCounter[result]--; format(string, sizeof(string), "* %s Abre A mala do carro e Retirar uma arma.", pname); ProxDetector(30.0, playerid, string, CHAT1, CHAT1, CHAT1, CHAT1, CHAT1); return 1; } else { SendClientMessage(playerid, GREY, "porta-mala estб vazio! "); return 1; } } default: { SendClientMessage(playerid, GREY, "Foi encontrado mais de um carro na бrea."); return 1; } } return 1; } else if(strcmp(x_nr,"colocarcolete",true) == 0) { new counter = 0; new result; for(new i; i != MAX_VEHICLES; i++) { new dist = CheckPlayerDistanceToVehicle(3.5, playerid, i); if(dist) { result = i; counter++; } } switch(counter) { case 0: { SendClientMessage(playerid, GREY, "Nenhum carro com o porta-malas perto de vocк"); return 1; } case 1: { if(IsPlayerInAnyVehicle(playerid)) { SendClientMessage(playerid, GREY, "Vocк nгo pode abrir o porta-malas, enquanto vocк estб no carro"); return 1; } /*if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 440 || GetVehicleModel(GetPlayerVehicleID(playerid)) != 456 || GetVehicleModel(GetPlayerVehicleID(playerid)) != 498) { SendClientMessage(playerid, GREY, " This vehicle doesn't have the trunk !"); return 1; }*/ new Float:plyArmour; GetPlayerArmour(playerid, plyArmour); if(plyArmour != 0) { SafeSetPlayerArmour(playerid, 0); vehTrunkArmour[result] = plyArmour; format(string, sizeof(string), "* %s Retira seu colete do corpo e coloca no porta-mala.", pname); ProxDetector(30.0, playerid, string, CHAT1, CHAT1, CHAT1, CHAT1, CHAT1); return 1; } else { SendClientMessage(playerid, GREY, " Vocк nгo tem nenhum Coletes а prova de bala"); return 1; } } default: { SendClientMessage(playerid, GREY, "Foi encontrado mais de um carro na бrea."); return 1; } } return 1; } else if(strcmp(x_nr,"pegarcolete",true) == 0) { new counter = 0; new result; for(new i; i != MAX_VEHICLES; i++) { new dist = CheckPlayerDistanceToVehicle(3.5, playerid, i); if(dist) { result = i; counter++; } } switch(counter) { case 0: { SendClientMessage(playerid, GREY, "Nenhum carro com o porta-malas perto de vocк"); return 1; } case 1: { if(IsPlayerInAnyVehicle(playerid)) { SendClientMessage(playerid, GREY, "Vocк nгo pode abrir o Porta-Malas, enquanto vocк estб no carro"); return 1; } /*if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 440 || GetVehicleModel(GetPlayerVehicleID(playerid)) != 456 || GetVehicleModel(GetPlayerVehicleID(playerid)) != 498) { SendClientMessage(playerid, GREY, " This vehicle doesn't have the trunk !"); return 1; }*/ if(vehTrunkArmour[result] != 0) { SafeSetPlayerArmour(playerid, vehTrunkArmour[result]); vehTrunkArmour[result] = 0; format(string, sizeof(string), "* %s Retira o Coletes а prova de bala do porta-malas.", pname); ProxDetector(30.0, playerid, string, CHAT1, CHAT1, CHAT1, CHAT1, CHAT1); return 1; } else { SendClientMessage(playerid, GREY, "Nгo hб nenhuma Coletes а prova de bala no porta-mala! "); return 1; } } default: { SendClientMessage(playerid, GREY, "Foi encontrado mais de um carro na бrea."); return 1; } } return 1; } else if(strcmp(x_nr,"olhar",true) == 0) { if(IsPlayerAdmin(playerid)) { new counter = 0; new result; for(new i; i != MAX_VEHICLES; i++) { new dist = CheckPlayerDistanceToVehicle(3.5, playerid, i); if(dist) { result = i; counter++; } } switch(counter) { case 0: { SendClientMessage(playerid, GREY, "Nenhum carro com o Porto-Malas perto de vocк"); } case 1: { if(IsPlayerInAnyVehicle(playerid)) { SendClientMessage(playerid, GREY, "Vocк nгo pode abrir o porta-malas, enquanto vocк estб no carro"); return 1; } /*if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 440 || GetVehicleModel(GetPlayerVehicleID(playerid)) != 456 || GetVehicleModel(GetPlayerVehicleID(playerid)) != 498) { SendClientMessage(playerid, GREY, " This vehicle doesn't have the trunk !"); return 1; }*/ SendClientMessage(playerid, LIGHTBLUE, "|_______ Porta-Malas _______|"); for(new slot = 1; slot != MAX_TRUNK_SLOTS; slot++) { new gunname[100]; if(vehTrunk[result][slot] != 0) { GetWeaponName(vehTrunk[result][slot], gunname, sizeof(gunname)); format(string, sizeof(string), "| Slot %i: %s (Muniзгo: %i)", slot, gunname, vehTrunkAmmo[result][slot]); SendClientMessage(playerid, WHITE, string); } else { format(string, sizeof(string), "| Slot %i: Livre (Muniзгo: N/A)", slot); SendClientMessage(playerid, WHITE, string); } } format(string, sizeof(string), "| Colete: %f%", vehTrunkArmour[result]); SendClientMessage(playerid, WHITE, string); format(string, sizeof(string), "* %s abre o porta-malas e checa o que hб dentro.", pname); ProxDetector(30.0, playerid, string, CHAT1, CHAT1, CHAT1, CHAT1, CHAT1); return 1; } default: { SendClientMessage(playerid, GREY, "Foi encontrado mais de um carro na бrea."); return 1; } } } else { SendClientMessage(playerid, GREY, "Vocк nгo й um administrador!"); return 1; } return 1; } return 1; } return 0; } 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; } stock CheckPlayerDistanceToVehicle(Float:radi, playerid, vehicleid) { if(IsPlayerConnected(playerid)) { new Float:PX,Float:PY,Float:PZ,Float:X,Float:Y,Float:Z; GetPlayerPos(playerid,PX,PY,PZ); GetVehiclePos(vehicleid, X,Y,Z); new Float:Distance = (X-PX)*(X-PX)+(Y-PY)*(Y-PY)+(Z-PZ)*(Z-PZ); if(Distance <= radi*radi) { return 1; } } return 0; } forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5); public ProxDetector(Float:radi, playerid, string[],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) && (GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i))) { if(!BigEar[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, string); } else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8))) { SendClientMessage(i, col2, string); } else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4))) { SendClientMessage(i, col3, string); } else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2))) { SendClientMessage(i, col4, string); } else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi))) { SendClientMessage(i, col5, string); } } else { SendClientMessage(i, col1, string); } } } }//not connected return 1; } forward RemovePlayerWeapon(playerid, weaponid); public RemovePlayerWeapon(playerid, weaponid) { new plyWeapons[12] = 0; new plyAmmo[12] = 0; for(new slot = 0; slot != 12; slot++) { new wep, ammo; GetPlayerWeaponData(playerid, slot, wep, ammo); if(wep != weaponid && ammo != 0) { GetPlayerWeaponData(playerid, slot, plyWeapons[slot], plyAmmo[slot]); } } SafeResetPlayerWeapons(playerid); for(new slot = 0; slot != 12; slot++) { if(plyAmmo[slot] != 0) { SafeGivePlayerWeapon(playerid, plyWeapons[slot], plyAmmo[slot]); } } return 1; } forward SafeGivePlayerWeapon(plyid, weaponid, ammo); public SafeGivePlayerWeapon(plyid, weaponid, ammo) { new curHour, curMinute, curSecond; gettime(curHour, curMinute, curSecond); ScriptWeaponsUpdated[plyid] = 1; GivePlayerWeapon(plyid, weaponid, ammo); UpdateWeaponSlots(plyid); return 1; } forward SafeSetPlayerArmour(playerid, Float:armour); public SafeSetPlayerArmour(playerid, Float:armour) { SetPlayerArmour(playerid, armour); return 1; } forward SafeResetPlayerWeapons(plyid); public SafeResetPlayerWeapons(plyid) { new curHour, curMinute, curSecond; gettime(curHour, curMinute, curSecond); ScriptWeaponsUpdated[plyid] = 1; ResetPlayerWeapons(plyid); UpdateWeaponSlots(plyid); return 1; } forward split(const strsrc[], strdest[][], delimiter); public split(const strsrc[], strdest[][], delimiter) { new i, li; new aNum; new len; while(i <= strlen(strsrc)){ if(strsrc[i]==delimiter || i==strlen(strsrc)){ len = strmid(strdest[aNum], strsrc, li, i, 128); strdest[aNum][len] = 0; li = i+1; aNum++; } i++; } return 1; } forward UpdateWeaponSlots(plyid); public UpdateWeaponSlots(plyid) { new weaponid, ammo; for (new i=0; i<13; i++) { GetPlayerWeaponData(plyid, i, weaponid, ammo); ScriptWeapons[plyid][i] = weaponid; } ScriptWeaponsUpdated[plyid] = 0; return 1; }