Hallo,
Ich habe einen bug mit dem System /tasche, Und Zwar, kann man sich -Drpgen und -Mats geben,
wie kann ich das beheben?
hier mal die befehle:
//============== /VERSTAUEN ==================//
if(strcmp(cmd, "/verstauen", true) == 0)
{
if(IsPlayerConnected(playerid))
{
for(new i=0; i < MAX_PLAYERS; i++)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
if(IsACop(i))
{
if(ProxDetectorS(20.0, playerid, i))
{
SendClientMessage(playerid, COLOR_GRAD1, "Cops sind in der Nähe, du kannst nichst verstauen!");
return 1;
}
}
}
new namen[256];
namen = strtok(cmdtext, idx);
if(!strlen(namen))
{
SendClientMessage(playerid, COLOR_LIGHTBLUE, "|__________________ Befehlshilfe _________________|");
SendClientMessage(playerid, COLOR_GRAD1, "Benutzung: /verstauen [Name] ([Menge])");
SendClientMessage(playerid, COLOR_GRAD1, "Namen: Waffe1, Waffe2, Materialien, Drogen");
return 1;
}
if(strcmp(namen,"Waffe1", true) == 0)
{
new gunID = GetPlayerWeapon(playerid);
new gunAmmo = GetPlayerAmmo(playerid);
if(gunID != 0 && gunAmmo != 0)
{
PlayerInfo[playerid][pInvWeapon] = gunID;
PlayerInfo[playerid][pInvAmmo] = gunAmmo;
RemovePlayerWeapon(playerid, gunID);
GetPlayerName(playerid, sendername, sizeof(sendername));
new gunname[100];
GetWeaponName(gunID, gunname, sizeof(gunname));
format(string, sizeof(string), " %s in die Tasche verstaut.", gunname);
SendClientMessage(playerid, COLOR_GREY, string);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, "Du hast keine Waffe, die du in die Tasche verstauen kannst!");
return 1;
}
}
if(strcmp(namen,"Waffe2", true) == 0)
{
new gunID = GetPlayerWeapon(playerid);
new gunAmmo = GetPlayerAmmo(playerid);
if(gunID != 0 && gunAmmo != 0)
{
PlayerInfo[playerid][pInvWeapon2] = gunID;
PlayerInfo[playerid][pInvAmmo2] = gunAmmo;
RemovePlayerWeapon(playerid, gunID);
GetPlayerName(playerid, sendername, sizeof(sendername));
new gunname[100];
GetWeaponName(gunID, gunname, sizeof(gunname));
format(string, sizeof(string), " %s in die Tasche verstaut.", gunname);
SendClientMessage(playerid, COLOR_GREY, string);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, "Du hast keine Waffe, die du in die Tasche verstauen kannst!");
return 1;
}
}
if(strcmp(namen,"Drogen", true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "Benutzung: /verstauen Drogen [Menge]");
format(string, sizeof(string), "Du hast %d Drogen dabei.", PlayerInfo[playerid][pDrugs]);
SendClientMessage(playerid, COLOR_GRAD3, string);
return 1;
}
new tdrugs;
tdrugs = strval(tmp);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "Benutzung: /verstauen Drogen [Menge]");
format(string, sizeof(string), " Du hast %d Drogen dabei.", PlayerInfo[playerid][pDrugs]);
SendClientMessage(playerid, COLOR_GRAD3, string);
return 1;
}
if(tdrugs + PlayerInfo[playerid][pInvDrugs] > 60)
{
SendClientMessage(playerid, COLOR_GRAD1, "Du kannst maximal 60 Gramm Drogen in deiner Tasche verstauen!");
return 1;
}
PlayerInfo[playerid][pDrugs] -= tdrugs;
PlayerInfo[playerid][pInvDrugs] += tdrugs;
format(string, sizeof(string), "%d Gramm Drogen in die Tasche verstaut.", tdrugs);
SendClientMessage(playerid, COLOR_GRAD4, string);
return 1;
}
if(strcmp(namen,"Materialien", true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "Benutzung: /verstauen Materialien [Menge]");
format(string, sizeof(string), "Du hast %d Materialien dabei", PlayerInfo[playerid][pMats]);
SendClientMessage(playerid, COLOR_GRAD3, string);
return 1;
}
new matss;
matss = strval(tmp);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "Benutzung: /verstauen Materialien [Menge]");
format(string, sizeof(string), " Du hast %d Materialien dabei.", PlayerInfo[playerid][pMats]);
SendClientMessage(playerid, COLOR_GRAD3, string);
return 1;
}
if(matss + PlayerInfo[playerid][pInvMats] > 4000)
{
SendClientMessage(playerid, COLOR_GRAD1, "Du kannst maximal 4000 Materials in deiner Tasche verstauen!");
return 1;
}
if(matss > PlayerInfo[playerid][pMats])
{
SendClientMessage(playerid, COLOR_GRAD2, "So viele Materialien hast du dabei!");
return 1;
}
PlayerInfo[playerid][pMats] -= matss;
PlayerInfo[playerid][pInvMats] += matss;
format(string, sizeof(string), "%d Materialien in die Tasche verstaut.", matss);
SendClientMessage(playerid, COLOR_GRAD4, string);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "Ungültiger Name!");
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "Du musst dich erst einloggen!");
}
return 1;
}
//============= /nehmen =================//
if(strcmp(cmd, "/nehmen", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(IsPlayerInAnyVehicle(playerid))return SendClientMessage(playerid, COLOR_GRAD1, "Du kannast nix in einem Fahrzeug nehmen. ");
new namen[256];
namen = strtok(cmdtext, idx);
if(!strlen(namen))
{
SendClientMessage(playerid, COLOR_LIGHTBLUE, "|__________________ Befehlshilfe _________________|");
SendClientMessage(playerid, COLOR_GRAD1, "Benutzung: /nehmen [Name] ([Menge])");
SendClientMessage(playerid, COLOR_GRAD1, "Namen: Waffe1, Waffe2, Materialien, Drogen");
return 1;
}
if(strcmp(namen,"Waffe1", true) == 0)
{
if(PlayerInfo[playerid][pInvWeapon] != 0 && PlayerInfo[playerid][pInvAmmo] != 0)
{
new gunname[100];
GetWeaponName(PlayerInfo[playerid][pInvWeapon], gunname, sizeof(gunname));
SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pInvWeapon], PlayerInfo[playerid][pInvAmmo]);
format(string, sizeof(string), " %s aus der Tasche rausgeholt.", gunname);
SendClientMessage(playerid, COLOR_GREY, string);
PlayerInfo[playerid][pInvWeapon] = 0;
PlayerInfo[playerid][pInvAmmo] = 0;
}
else
{
SendClientMessage(playerid, COLOR_GREY, "Du hast keine Waffe in deiner Tasche!");
return 1;
}
}
else if(strcmp(namen,"Waffe2", true) == 0)
{
if(PlayerInfo[playerid][pInvWeapon2] != 0 && PlayerInfo[playerid][pInvAmmo2] != 0)
{
new gunname[100];
GetWeaponName(PlayerInfo[playerid][pInvWeapon2], gunname, sizeof(gunname));
SafeGivePlayerWeapon(playerid, PlayerInfo[playerid][pInvWeapon2], PlayerInfo[playerid][pInvAmmo2]);
format(string, sizeof(string), " %s aus der Tasche rausgeholt.", gunname);
SendClientMessage(playerid, COLOR_GREY, string);
PlayerInfo[playerid][pInvWeapon2] = 0;
PlayerInfo[playerid][pInvAmmo2] = 0;
}
else
{
SendClientMessage(playerid, COLOR_GREY, "Du hast keine Waffe in deiner Tasche!");
return 1;
}
}
else if(strcmp(namen,"Drogen", true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "Benutzung: /nehmen Drogen [Menge]");
format(string, sizeof(string), " Du hast %d Drogen in deiner Tasche.", PlayerInfo[playerid][pInvDrugs]);
SendClientMessage(playerid, COLOR_GRAD3, string);
return 1;
}
new tdrugs;
tdrugs = strval(tmp);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "Benutzung: /nehmen Drogen [Menge]");
format(string, sizeof(string), " Du hast %d Drogen in deiner Tasche.", PlayerInfo[playerid][pInvDrugs]);
SendClientMessage(playerid, COLOR_GRAD3, string);
return 1;
}
if(tdrugs > PlayerInfo[playerid][pInvDrugs])
{
SendClientMessage(playerid, COLOR_GRAD2, "So viele Drogen hast du nicht in deiner Tasche!");
return 1;
}
PlayerInfo[playerid][pInvDrugs] -= tdrugs;
PlayerInfo[playerid][pDrugs] += tdrugs;
format(string, sizeof(string), "%d Gramm Drogen aus der Tasche genommen.", tdrugs);
SendClientMessage(playerid, COLOR_GRAD4, string);
return 1;
}
else if(strcmp(namen,"Materialien", true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "Benutzung: /nehmen Materialien [Menge]");
format(string, sizeof(string), "Du hast %d Materialien aus der Tasche genommen.", PlayerInfo[playerid][pBoxMats]);
SendClientMessage(playerid, COLOR_GRAD3, string);
return 1;
}
new matss;
matss = strval(tmp);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "Benutzung: /nehmen Materialien [Menge]");
format(string, sizeof(string), " Du hast %d Materialien aus der Tasche genommen.", PlayerInfo[playerid][pBoxMats]);
SendClientMessage(playerid, COLOR_GRAD3, string);
return 1;
}
if(matss > PlayerInfo[playerid][pInvMats])
{
SendClientMessage(playerid, COLOR_GRAD2, "So viele Materialien hast du nicht in deiner Tasche!");
return 1;
}
if(matss + PlayerInfo[playerid][pMats] > 2000)
{
SendClientMessage(playerid, COLOR_GRAD1, "Du kannst maximal 2000 Materialien tragen.");
return 1;
}
PlayerInfo[playerid][pInvMats] -= matss;
PlayerInfo[playerid][pMats] += matss;
format(string, sizeof(string), "%d Materialien aus der Tasche genommen.", matss);
SendClientMessage(playerid, COLOR_GRAD4, string);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "Ungültiger Name!");
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "Du musst dich erst einloggen!");
}
return 1;
}