11.11.2013, 22:35
Miren en mi GM tengo el siguiente bug: un jugador puede ofrecer un arma a otro jugador con el comando /dararma, y antes de que el otro la acepte con /aceptar arma el jugador que la ofrecio la guarda en el maletero con /gmaletero, luego acepta el arma y se duplica! ambos tienen el arma. Por favor ayuda aqui les mando los scripts de los comandos.
/dararma
pawn Код:
CMD:dararma(playerid, params[]) {
new string[128],id,weapon;
if(sscanf(params, "u", id))
return SendClientMessage(playerid, COLOR_GREY, "Uso: /dararma [playerid]");
if(GetPVarInt(playerid, "IsInArena") == 1) return SendClientMessageEx(playerid, COLOR_WHITE, "[ERROR]: No puedes usar este comando mientras estбs en el paintball.");
else if(Info[playerid][pEstado]==0)
{
if(id == playerid) return SendClientMessageEx(playerid, COLOR_GRAD1, "No puedes darte un arma a ti mismo!");
if(Info[id][pConnectTime] < 2 || Info[id][pWRestricted] > 0) return SendClientMessageEx(playerid, COLOR_GRAD2, "Ese jugador tiene restricciуn de armas.");
/*if(Info[playerid][pMember] != Info[id][pMember] && Info[playerid][pMember] > 0)
{
SendClientMessageEx(playerid, COLOR_GRAD1, "No puedes dar armas a los jugadores fuera de tu facciуn!");
return 1;
}*/
if(IsPlayerConnected(id)){
if(ProxDetectorS(6.0, playerid, id) && !IsPlayerInAnyVehicle(playerid)){
if(IsPlayerInAnyVehicle(id)) return SendClientMessageEx(playerid, COLOR_GRAD2, "No puedes dar un arma si el jugador esta en un vehнculos.");
weapon = GetPlayerWeapon(playerid);
switch(weapon)
{
case 16, 18, 35, 36, 37, 38, 39, 40, 44, 45, 46, 0: SendClientMessage(playerid, COLOR_GREY, "Arma Invбlida.");
default:
{
format(string, sizeof(string), "Ofreciste a %s tu %s.", GetPlayerNameEx(id), WeaponNames[weapon]);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "%s te ha ofrecido su %s - Usa /aceptar arma para recibirla.", GetPlayerNameEx(playerid), WeaponNames[weapon]);
SendClientMessage(id, COLOR_LIGHTBLUE, string);
SetPVarInt(id,"gunID",playerid);
SetPVarInt(playerid,"gun",weapon);
SetPVarInt(playerid,"slot",GetWeaponSlot(weapon));
}
}
}
else SendClientMessage(playerid, COLOR_GREY, "Tu estas lejos del jugador o en un vehнculo.");
}
else SendClientMessage(playerid, COLOR_GREY, "La ID que has ingresado es invбlida.");
}
else SendClientMessage(playerid, COLOR_GREY, "No puedes hacer esto mientras estas tazeado, esposado o congelado.");
return 1;
}
/gmaletero
pawn Код:
CMD:gmaletero(playerid, params[])
{
if(GetPVarInt(playerid, "IsInArena") == 1) return SendClientMessageEx(playerid, COLOR_WHITE, "[ERROR]: No puedes usar este comando mientras estбs en el paintball.");
if(GetPVarInt( playerid, "EventToken") != 0) return SendClientMessageEx(playerid, COLOR_GREY, "[ERROR]: No puedes usar este comando mientras estбs en un evento.");
if(IsPlayerInAnyVehicle(playerid)) { SendClientMessageEx(playerid, COLOR_WHITE, "[ERROR]: No puedes hacer esto mientras estar en el interior del vehнculo!"); return 1; }
if(GetPVarInt(playerid, "EMSAttempt") != 0) return SendClientMessageEx(playerid, COLOR_GRAD2, "[ERROR]: No puedes usar este comando ahora mismo.");
new string[128], weaponchoice[32], slot;
if(sscanf(params, "s[32]d", weaponchoice, slot)) return SendClientMessageEx(playerid, COLOR_WHITE, "USA: /gmaletero [arma] [slot]");
new pvid = -1, Float: x, Float: y, Float: z;
for(new d = 0 ; d < MAX_PLAYERVEHICLES; d++)
{
if(PlayerVehicleInfo[playerid][d][pvId] != INVALID_PLAYER_VEHICLE_ID) GetVehiclePos(PlayerVehicleInfo[playerid][d][pvId], x, y, z);
if(IsPlayerInRangeOfPoint(playerid, 3.0, x, y, z))
{
pvid = d;
break;
}
}
if(pvid == -1) return SendClientMessageEx(playerid,COLOR_GREY,"[ERROR]: No estбs cerca de un vehнculo que sea tuyo.");
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(PlayerVehicleInfo[playerid][pvid][pvId],engine,lights,alarm,doors,bonnet,boot,objective);
if(boot == VEHICLE_PARAMS_OFF || boot == VEHICLE_PARAMS_UNSET) return SendClientMessageEx(playerid, COLOR_GRAD3, "[ERROR]: No se puede poner armas en el interior del maletero si estб cerrado! (/v maletero para abrirlo)");
if(GetVehicleModel(PlayerVehicleInfo[playerid][pvid][pvId]) == 481 || GetVehicleModel(PlayerVehicleInfo[playerid][pvid][pvId]) == 510) return SendClientMessageEx(playerid,COLOR_GREY,"[ERROR]: Este coche no tiene maletero.");
//new Float: Health;
//GetPlayerHealth(playerid, Health);
//if(Health < 80.0) return SendClientMessageEx(playerid,COLOR_GREY,"You cannot store weapons in a car when your health lower than 80.");
if (GetPVarInt(playerid, "GiveWeaponTimer") > 0)
{
format(string, sizeof(string), " Necesitas esperar %d segundos despuйs de haber guardado un arma.", GetPVarInt(playerid, "GiveWeaponTimer"));
SendClientMessageEx(playerid,COLOR_GREY,string);
return 1;
}
new maxslots = PlayerVehicleInfo[playerid][pvid][pvWepUpgrade]+1;
if(slot > maxslots)
{
SendClientMessageEx(playerid, COLOR_GREY, "[ERROR]: Slot Invбlido. [/gunlocker]");
return 1;
}
if( PlayerVehicleInfo[playerid][pvid][pvWeapons][slot-1] != 0)
{
SendClientMessageEx(playerid, COLOR_GREY, "[ERROR]: Tienes armas guardadas en ese slot.");
return 1;
}
new weapon;
if(strcmp(weaponchoice, "sdpistol", true, strlen(weaponchoice)) == 0)
{
if( Info[playerid][pWeapons][2] == 23)
{
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "Has guardado una pistola SD en tu maletero.");
weapon = Info[playerid][pWeapons][2];
format(string,sizeof(string), "* %s guarda un pistola SD en su maletero.", GetPlayerNameEx(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
SetPVarInt(playerid, "GiveWeaponTimer", 10); SetTimerEx("OtherTimerEx", 1000, false, "ii", playerid, TYPE_GIVEWEAPONTIMER);
}
}
else if(strcmp(weaponchoice, "deagle", true, strlen(weaponchoice)) == 0)
{
if( Info[playerid][pWeapons][2] == 24)
{
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "Has guardado un Desert Eagle en tu maletero.");
weapon = Info[playerid][pWeapons][2];
format(string,sizeof(string), "* %s guarda un Desert Eagle en su maletero.", GetPlayerNameEx(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
SetPVarInt(playerid, "GiveWeaponTimer", 10); SetTimerEx("OtherTimerEx", 1000, false, "ii", playerid, TYPE_GIVEWEAPONTIMER);
}
}
else if(strcmp(weaponchoice, "shotgun", true, strlen(weaponchoice)) == 0)
{
if( Info[playerid][pWeapons][3] == 25)
{
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "Has guardado un Shotgun en tu maletero.");
weapon = Info[playerid][pWeapons][3];
format(string,sizeof(string), "* %s guarda un Shotgun en su maletero.", GetPlayerNameEx(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
SetPVarInt(playerid, "GiveWeaponTimer", 10); SetTimerEx("OtherTimerEx", 1000, false, "ii", playerid, TYPE_GIVEWEAPONTIMER);
}
}
else if(strcmp(weaponchoice, "spas12", true, strlen(weaponchoice)) == 0)
{
if( Info[playerid][pWeapons][3] == 27)
{
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "Has guardado una CombatShotgun en tu maletero.");
weapon = Info[playerid][pWeapons][3];
format(string,sizeof(string), "* %s guarda una Combat Shotgun en su maletero.", GetPlayerNameEx(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
SetPVarInt(playerid, "GiveWeaponTimer", 10); SetTimerEx("OtherTimerEx", 1000, false, "ii", playerid, TYPE_GIVEWEAPONTIMER);
}
}
else if(strcmp(weaponchoice, "mp5", true, strlen(weaponchoice)) == 0)
{
if( Info[playerid][pWeapons][4] == 29)
{
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "Has guardado un MP5 en tu maletero.");
weapon = Info[playerid][pWeapons][4];
format(string,sizeof(string), "* %s guarda un MP5 en su maletero.", GetPlayerNameEx(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
SetPVarInt(playerid, "GiveWeaponTimer", 10); SetTimerEx("OtherTimerEx", 1000, false, "ii", playerid, TYPE_GIVEWEAPONTIMER);
}
}
else if(strcmp(weaponchoice, "ak47", true, strlen(weaponchoice)) == 0)
{
if( Info[playerid][pWeapons][5] == 30)
{
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "Has guardado una AK-47 en tu maletero.");
weapon = Info[playerid][pWeapons][5];
format(string,sizeof(string), "* %s guarda una AK-47 en su maletero.", GetPlayerNameEx(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
SetPVarInt(playerid, "GiveWeaponTimer", 10); SetTimerEx("OtherTimerEx", 1000, false, "ii", playerid, TYPE_GIVEWEAPONTIMER);
}
}
else if(strcmp(weaponchoice, "m4", true, strlen(weaponchoice)) == 0)
{
if( Info[playerid][pWeapons][5] == 31)
{
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "Has guardado una M4 en tu maletero.");
weapon = Info[playerid][pWeapons][5];
format(string,sizeof(string), "* %s guarda una M4 en su maletero.", GetPlayerNameEx(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
SetPVarInt(playerid, "GiveWeaponTimer", 10); SetTimerEx("OtherTimerEx", 1000, false, "ii", playerid, TYPE_GIVEWEAPONTIMER);
}
}
else if(strcmp(weaponchoice, "rifle", true, strlen(weaponchoice)) == 0)
{
if( Info[playerid][pWeapons][6] == 33)
{
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "Has guardado un rifle en tu maletero.");
weapon = Info[playerid][pWeapons][6];
format(string,sizeof(string), "* %s guarda un rifle en su maletero.", GetPlayerNameEx(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
SetPVarInt(playerid, "GiveWeaponTimer", 10); SetTimerEx("OtherTimerEx", 1000, false, "ii", playerid, TYPE_GIVEWEAPONTIMER);
}
}
else if(strcmp(weaponchoice, "sniper", true, strlen(weaponchoice)) == 0)
{
if( Info[playerid][pWeapons][6] == 34)
{
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "Has guardado un sniper en tu maletero.");
weapon = Info[playerid][pWeapons][6];
format(string,sizeof(string), "* %s guarda un sniper en su maletero.", GetPlayerNameEx(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
SetPVarInt(playerid, "GiveWeaponTimer", 10); SetTimerEx("OtherTimerEx", 1000, false, "ii", playerid, TYPE_GIVEWEAPONTIMER);
}
}
if(weapon == 0) return SendClientMessageEx(playerid, COLOR_GREY, "No tienes esa arma");
if(PlayerVehicleInfo[playerid][pvid][pvWeapons][slot-1] == 0)
{
PlayerVehicleInfo[playerid][pvid][pvWeapons][slot-1] = weapon;
RemovePlayerWeapon(playerid, weapon);
return 1;
}
else { SendClientMessageEx(playerid,COLOR_GREY," Nombre invбlido!"); return 1; }
}
/aceptar arma
pawn Код:
else if(strcmp(params, "arma", true) == 0) {
new
playerOffering = GetPVarInt(playerid,"gunID"),
weaponOffering = GetPVarInt(GetPVarInt(playerid,"gunID"),"gun"),
slotOffering = GetPVarInt(GetPVarInt(playerid,"gunID"),"slot"),
wstring[128];
if(weaponOffering != 0 && slotOffering != 0) {
if(ProxDetectorS(6.0, playerid, playerOffering) && !IsPlayerInAnyVehicle(playerid) && !IsPlayerInAnyVehicle(playerOffering)) {
if(Info[playerOffering][pEstado]!=0) {
return SendClientMessage(playerid, COLOR_GREY, "El jugador que quiere venderte estб tazeado, esposado o congelado.");
}
else if(Info[playerid][pEstado]!=0) {
return SendClientMessage(playerid, COLOR_GREY, "No puedes hacer esto mientras estas tazeado, esposado o congelado.");
}
else {
RemovePlayerWeapon(playerOffering, weaponOffering);
GivePlayerValidWeapon(playerid, weaponOffering);
format(wstring, sizeof(wstring), "Aceptas el %s de %s.", WeaponNames[weaponOffering], GetPlayerNameEx(playerOffering));
SendClientMessage(playerid, COLOR_WHITE, wstring);
format(wstring, sizeof(wstring), "%s aceptу tu %s que le ofreciste.", GetPlayerNameEx(playerid), WeaponNames[weaponOffering]);
SendClientMessage(playerOffering, COLOR_WHITE, wstring);
format(wstring, sizeof(wstring), "* %s le da su %s a %s.", GetPlayerNameEx(playerOffering), WeaponNames[weaponOffering], GetPlayerNameEx(playerid));
ProxDetector(30.0, playerid, wstring, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
DeletePVar(playerOffering,"gun");
DeletePVar(playerid,"gunID");
DeletePVar(playerOffering,"slot");
}
}
else SendClientMessage(playerid, COLOR_GREY, "Estбs muy lejos de la persona o estб en un vehнculo.");
}
else SendClientMessage(playerid, COLOR_GREY, "Nadie te ha ofrecido un arma.");
}