Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- //--------------Porta Malas-----------------
- new PortaMalasNome[MAX_VEHICLES][6][128];
- new PortaMalasIdent[MAX_VEHICLES][6];
- new PortaMalasQuant[MAX_VEHICLES][6];
- new bool: PortaMalasUsado[MAX_VEHICLES][6];
- /*
- Sistema de Informacao do Player:
- PI[playerid][pInfo] (para quem conhece GodFather: PlayerInfo[playerid][pInfo])
- */
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- // ---------------- Porta Malas---------------------------
- if(strcmp(cmd, "/portamalas", true) == 0)
- {
- new vehicleid = GetNearestVehicle(playerid, 10);
- new Float: Pos[3];
- GetVehiclePos(vehicleid, Pos[0], Pos[1], Pos[2]);
- if(vehicleid == 0)// se GetNearestVehicle n encontrar nenhum, a funcao retorna 0, dai essa linha ai :D
- return Aviso(playerid, "Nenhum veiculo perto de você");
- tmp = strtok(cmdtext, idx);
- if(strlen(tmp) == 0)
- return Aviso(playerid, "USO: /portamalas [colocar/retirar/ver]");
- new text[52];
- strmid(text, tmp, 0, strlen(tmp));
- new engine,lights,alarm,doors,bonnet,boot,objective;
- GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
- SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,1,objective);
- if(strcmp(text, "colocar", true) == 0)
- {
- tmp = strtok(cmdtext, idx);
- new slotlivre, slotsusados;
- for(new slotid = 0; slotid < 6; slotid ++)
- {
- if(PortaMalasUsado[vehicleid][slotid] == false)
- {
- slotlivre = slotid;
- goto colocar_next;
- }
- if(PortaMalasUsado[vehicleid][slotid] == true)
- {
- slotsusados++;
- }
- }
- colocar_next:
- if(slotsusados == 6)
- {
- Aviso(playerid, "Porta Malas Cheio");
- GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
- SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
- return 1;
- }
- if(strlen(tmp) == 0)
- {
- Aviso(playerid, "USO: /portamalas Colocar [Drogas/Materiais/Arma]");
- GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
- SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
- return 1;
- }
- new Coloca[52];
- strmid(Coloca, tmp, 0, strlen(tmp));
- if(strcmp(Coloca, "Drogas", true) == 0)
- {
- if(PI[playerid][pDrogas] == 0)
- {
- Aviso(playerid, "Você não tem Drogas");
- GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
- SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
- return 1;
- }
- tmp = strtok(cmdtext, idx);
- if(strlen(tmp) == 0)
- {
- Aviso(playerid, "USO: /portamalas Colocar Drogas [quantidade]");
- GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
- SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
- return 1;
- }
- new quant;
- quant = strval(tmp);
- if(quant > PI[playerid][pDrogas])
- {
- Aviso(playerid, "Você não tem essas drogas no Bolso");
- GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
- SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
- return 1;
- }
- PI[playerid][pDrogas] -= quant;
- PortaMalasQuant[vehicleid][slotlivre] += quant;
- PortaMalasNome[vehicleid][slotlivre] = "Drogas";
- PortaMalasIdent[vehicleid][slotlivre] = 0;
- PortaMalasUsado[vehicleid][slotlivre] = true;
- format(string, sizeof(string), "Você Depositou %s Drogas. O veiculo tem agora %s", quant, PortaMalasQuant[vehicleid][slotlivre]);
- SendClientMessage(playerid, 0xEE82EEFF, string);
- GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
- SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
- return 1;
- }
- if(strcmp(Coloca, "Materiais", true) == 0)
- {
- if(PI[playerid][pMaterial] == 0)
- {
- Aviso(playerid, "Você não tem Materiais");
- GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
- SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
- return 1;
- }
- tmp = strtok(cmdtext, idx);
- if(strlen(tmp) == 0)
- {
- Aviso(playerid, "USO: /portamalas Colocar Materiais [quantidade]");
- GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
- SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
- return 1;
- }
- new quant;
- quant = strval(tmp);
- if(quant > PI[playerid][pMaterial])
- {
- Aviso(playerid, "Você não tem essas drogas no Bolso");
- GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
- SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
- return 1;
- }
- PI[playerid][pMaterial] -= quant;
- PortaMalasQuant[vehicleid][slotlivre] += quant;
- PortaMalasNome[vehicleid][slotlivre] = "Materiais";
- PortaMalasIdent[vehicleid][slotlivre] = 0;
- PortaMalasUsado[vehicleid][slotlivre] = true;
- format(string, sizeof(string), "Você Depositou %s Materiais. O veiculo tem agora %s", quant, PortaMalasQuant[vehicleid][slotlivre]);
- SendClientMessage(playerid, 0xEE82EEFF, string);
- GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
- SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
- return 1;
- }
- if(strcmp(Coloca, "Arma", true) == 0)
- {
- tmp = strtok(cmdtext, idx);
- if(strlen(tmp) == 0)
- {
- Aviso(playerid, "USO: /portamalas Colocar Arma");
- GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
- SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
- return 1;
- }
- new colArma = GetPlayerWeapon(playerid);
- if(colArma < 16)
- {
- Aviso(playerid, "Você nao pode guardar essa arma");
- GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
- SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
- return 1;
- }
- new ammo = GetPlayerAmmo(playerid);
- SetPlayerAmmo(playerid, colArma, 0);//Remove a Arma
- PortaMalasNome[vehicleid][slotlivre] = "Arma";
- PortaMalasIdent[vehicleid][slotlivre] = colArma;
- PortaMalasQuant[vehicleid][slotlivre] = ammo;
- PortaMalasUsado[vehicleid][slotlivre] = true;
- new nomearma[32];
- GetWeaponName(colArma, nomearma, sizeof(nomearma));
- format(string, sizeof(string), "Você colocou %d balas de %s", ammo, nomearma);
- SendClientMessage(playerid, 0xEE82EEFF, string);
- GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
- SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
- return 1;
- }
- return 1;
- }
- if(strcmp(text, "retirar", true) == 0)
- {
- tmp = strtok(cmdtext, idx);
- if(strlen(tmp) == 0)
- {
- Aviso(playerid, "USO: /portamalas Retirar [Slot]");
- GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
- SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
- return 1;
- }
- new slotid;
- slotid = strval(tmp);
- if(slotid < 0 || slotid > 5)
- {
- Aviso(playerid, "Slot entre 0 e 5");
- GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
- SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
- return 1;
- }
- if(PortaMalasUsado[vehicleid][slotid] == false)
- {
- Aviso(playerid, "Slot Vazio");
- GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
- SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
- return 1;
- }
- if(strcmp(PortaMalasNome[vehicleid][slotid], "Drogas", true) == 0)
- {
- PI[playerid][pDrogas] += PortaMalasQuant[vehicleid][slotid];
- format(string, sizeof(string), "Você retirou %d drogas do veiculo", PortaMalasQuant[vehicleid][slotid]);
- SendClientMessage(playerid, 0xFF8C69FF, string);
- PortaMalasNome[vehicleid][slotid] = " ";
- PortaMalasIdent[vehicleid][slotid] = 0;
- PortaMalasQuant[vehicleid][slotid] = 0;
- PortaMalasUsado[vehicleid][slotid] = false;
- GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
- SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
- return 1;
- }
- if(strcmp(PortaMalasNome[vehicleid][slotid], "Materiais", true) == 0)
- {
- PI[playerid][pMaterial] += PortaMalasQuant[vehicleid][slotid];
- format(string, sizeof(string), "Você retirou %d materiais do veiculo", PortaMalasQuant[vehicleid][slotid]);
- SendClientMessage(playerid, 0xFF8C69FF, string);
- PortaMalasNome[vehicleid][slotid] = " ";
- PortaMalasIdent[vehicleid][slotid] = 0;
- PortaMalasQuant[vehicleid][slotid] = 0;
- PortaMalasUsado[vehicleid][slotid] = false;
- GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
- SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
- return 1;
- }
- if(strcmp(PortaMalasNome[vehicleid][slotid], "Arma", true) == 0)
- {
- GivePlayerWeapon(playerid, PortaMalasIdent[vehicleid][slotid], PortaMalasQuant[vehicleid][slotid]);
- new ArmaName[32];
- GetWeaponName(PortaMalasIdent[vehicleid][slotid], ArmaName, sizeof(ArmaName));
- format(string, sizeof(string), "Você retirou uma %s com %d balas", ArmaName, PortaMalasQuant[vehicleid][slotid]);
- SendClientMessage(playerid, 0xFF8C69FF, string);
- PortaMalasNome[vehicleid][slotid] = " ";
- PortaMalasIdent[vehicleid][slotid] = 0;
- PortaMalasQuant[vehicleid][slotid] = 0;
- PortaMalasUsado[vehicleid][slotid] = false;
- GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
- SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
- return 1;
- }
- return 1;
- }
- if(strcmp(text, "ver", true) == 0)
- {
- new slotid = 0;
- while(slotid < 6)
- {
- if(PortaMalasUsado[vehicleid][slotid] == true)
- {
- new Name[52];
- strmid(Name, PortaMalasNome[vehicleid][slotid], 0, strlen(PortaMalasNome[vehicleid][slotid]));
- if(strcmp(Name, "Arma", true) == 0)
- {
- new armaName[32];
- GetWeaponName(PortaMalasIdent[vehicleid][slotid], armaName, sizeof(armaName));
- format(string, sizeof(string), "Slot %d: %s %s : %d Balas", slotid, PortaMalasNome[vehicleid][slotid], armaName, PortaMalasQuant[vehicleid][slotid]);
- SendClientMessage(playerid, 0xF0FFFFFF, string);
- }
- else if(strcmp(Name, "Materiais", true) == 0)
- {
- format(string, sizeof(string), "Slot %d: %s : %d Materiais", slotid, PortaMalasNome[vehicleid][slotid], PortaMalasQuant[vehicleid][slotid]);
- SendClientMessage(playerid, 0xF0FFFFFF, string);
- }
- else if(strcmp(Name, "Drogas", true) == 0)
- {
- format(string, sizeof(string), "Slot %d: %s : %d Drogas", slotid, PortaMalasNome[vehicleid][slotid], PortaMalasQuant[vehicleid][slotid]);
- SendClientMessage(playerid, 0xF0FFFFFF, string);
- }
- }
- slotid++;
- }
- GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
- SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
- return 1;
- }
- return 1;
- }
- return 1;//Fim Public OnPlayerCommandText
- }
- stock GetNearestVehicle(playerid, Float:range)//Creditos a alguem do Forum SAMP, n lembro o nome
- {
- new Float:p_X;
- new Float:p_Y;
- new Float:p_Z;
- new Float:Distance;
- new Float:PretendentDistance = range +1;
- new Pretendent;
- GetPlayerPos(playerid, p_X, p_Y, p_Z);
- for(new vehicleid=1; vehicleid < MAX_VEHICLES; vehicleid++)
- {
- Distance = GetVehicleDistanceFromPoint(vehicleid, p_X, p_Y, p_Z);
- if(Distance <= range && Distance <= PretendentDistance)
- {
- Pretendent = vehicleid;
- PretendentDistance = Distance;
- }
- }
- return Pretendent;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement