3 Bugs - Need Help
#1

Hello.

I have 3 system in my gamemode that are bugged. Please help me.


First - Anti-Weapon Spawn

- I don't know why but people are banned when they use /guardararmapasta (get the bag weapon) and /tirararmapasta (put the weapon in the bag). These comands use RemovePlayerWeapon.


System:

Код:
forward DarArmaPlayer(playerid, weaponid, ammo);
forward RemovePlayerWeapon(playerid, weaponid);
forward TirarArmaPlayer(playerid);
forward ArmaTimerReset(playerid);
new ArmaTimerPause[MAX_PLAYERS];
new GivedPlayerWeapon[MAX_PLAYERS+5][60];


public DarArmaPlayer(playerid, weaponid, ammo)
{
	if(ArmaTimerPause[playerid]==0)
	{
    GivedPlayerWeapon[playerid][weaponid]=1;
    GivePlayerWeapon(playerid, weaponid, ammo);
    ArmaTimerPause[playerid]=1;
    SetTimerEx("ArmaTimerReset", 1000, false, "i", playerid);
    }
    else
 	{
        SetTimerEx("DarArmaPlayer", 1000, false, "iii", playerid, weaponid, ammo);
    }
    return 1;
}

#define GivePlayerWeapon DarArmaPlayer

public TirarArmaPlayer(playerid)
{
    ResetPlayerWeapons(playerid);
	for(new i=0; i<60; i++)
	{

    GivedPlayerWeapon[playerid][i]=0;

	}
	GivedPlayerWeapon[playerid][0]=1;
	GivedPlayerWeapon[playerid][1]=1;
	GivedPlayerWeapon[playerid][46]=1;
	GivedPlayerWeapon[playerid][47]=1;
	GivedPlayerWeapon[playerid][49]=1;
	GivedPlayerWeapon[playerid][50]=1;
	GivedPlayerWeapon[playerid][51]=1;
	GivedPlayerWeapon[playerid][53]=1;
	GivedPlayerWeapon[playerid][54]=1;
	ArmaTimerPause[playerid]=1;
	SetTimerEx("ArmaTimerReset", 1000, false, "i", playerid);
    return 1;
}

public ArmaTimerReset(playerid)
{
    ArmaTimerPause[playerid]=0;
}


public RemovePlayerWeapon(playerid, weaponid)
{
	new plyWeapons[12] = 0;
	new plyAmmo[12] = 0;
	for(new sslot = 0; sslot != 12; sslot++)
	{
		new wep, ammo;
		GetPlayerWeaponData(playerid, sslot, wep, ammo);
		if(wep != weaponid && ammo != 0) GetPlayerWeaponData(playerid, sslot, plyWeapons[sslot], plyAmmo[sslot]);
	}
	ArmaTimerPause[playerid]=1;
	ResetPlayerWeapons(playerid);
	for(new sslot = 0; sslot != 12; sslot++)
	{
	    if(plyAmmo[sslot] != 0)
		{
		    GivedPlayerWeapon[playerid][plyWeapons[sslot]]=1;
			GivePlayerWeapon(playerid, plyWeapons[sslot], plyAmmo[sslot]);
		}
	}
	return 1;
}

Second - PayDay Bug

My PayDay/PayCheck is showing "SERVER UNKWNOW COMMAND".

I know what part of PayCheck it's bugged, but I don't know why.. I'll put it here:

Код:
new cfaction;
new faction = PlayerInfo[i][Faction];

if(faction != 255 && faction < 19 && PlayerInfo[i][Rank] < 19){
						new ftipo = DynamicFactions[PlayerInfo[i][Faction]][fType];
						if(faction != 255 && ftipo != 5 && ftipo != 6 && ftipo != 7)
						{
						    cfaction = DynamicFactionsSalario[faction][PlayerInfo[i][Rank]];
						    new rank[35];
						    if(PlayerInfo[i][Rank]==1) format(rank, sizeof(rank), "%s", DynamicFactions[PlayerInfo[i][Faction]][fRank1]);
						    if(PlayerInfo[i][Rank]==2) format(rank, sizeof(rank), "%s", DynamicFactions[PlayerInfo[i][Faction]][fRank2]);
						    if(PlayerInfo[i][Rank]==3) format(rank, sizeof(rank), "%s", DynamicFactions[PlayerInfo[i][Faction]][fRank3]);
						    if(PlayerInfo[i][Rank]==4) format(rank, sizeof(rank), "%s", DynamicFactions[PlayerInfo[i][Faction]][fRank4]);
						    if(PlayerInfo[i][Rank]==5) format(rank, sizeof(rank), "%s", DynamicFactions[PlayerInfo[i][Faction]][fRank5]);
						    if(PlayerInfo[i][Rank]==6) format(rank, sizeof(rank), "%s", DynamicFactions[PlayerInfo[i][Faction]][fRank6]);
						    if(PlayerInfo[i][Rank]==7) format(rank, sizeof(rank), "%s", DynamicFactions[PlayerInfo[i][Faction]][fRank7]);
						    if(PlayerInfo[i][Rank]==8) format(rank, sizeof(rank), "%s", DynamicFactions[PlayerInfo[i][Faction]][fRank8]);
						    if(PlayerInfo[i][Rank]==9) format(rank, sizeof(rank), "%s", DynamicFactions[PlayerInfo[i][Faction]][fRank9]);
						    if(PlayerInfo[i][Rank]==10) format(rank, sizeof(rank), "%s", DynamicFactions[PlayerInfo[i][Faction]][fRank10]);
						    if(ftipo==8)
						    {
    							PlayerInfo[i][Bankc] += cfaction;
			    				DynamicFactions[0][fBank]-=cfaction;
								format(wstring, sizeof(wstring), "Salбrio:%d$ [ Rank: %s ] [Balanзo Faction:%d$ ]", cfaction, rank, DynamicFactions[faction][fBank]);
 								SendClientMessage(i, COLOR_WHITE, wstring);
							}
							else
							{
						        new cfactionmetade;
								cfactionmetade = cfaction/2;
								if(DynamicFactions[PlayerInfo[i][Faction]][fBank] >= cfactionmetade)
								{
								    if(DynamicFactions[0][fBank] < cfactionmetade)
								    {
								    cfaction=cfactionmetade;
				    				PlayerInfo[i][Bankc] += cfactionmetade;
				    				DynamicFactions[PlayerInfo[i][Faction]][fBank]-=cfactionmetade;
									format(wstring, sizeof(wstring), "Dinheiro Recebido:%d$ [ Rank: %s ] [Balanзo Faction:%d$ ]", cfaction, rank, DynamicFactions[faction][fBank]);
        							SendClientMessage(i, COLOR_WHITE, wstring);
        							format(wstring, sizeof(wstring), "O governo nгo te pagou, por falta de fundos. Recebeste metade do salбrio por parte da tua faction.");
        							SendClientMessage(i, COLOR_WHITE, wstring);
								    }
								    else
								    {
				    				PlayerInfo[i][Bankc] += cfaction;
				    				DynamicFactions[PlayerInfo[i][Faction]][fBank]-=cfactionmetade;
				    				DynamicFactions[0][fBank]-=cfactionmetade;
									format(wstring, sizeof(wstring), "Salбrio:%d$ [ Rank: %s ] [Balanзo Faction:%d$ ]", cfaction, rank, DynamicFactions[faction][fBank]);
        							SendClientMessage(i, COLOR_WHITE, wstring);
									}
								}
								else
								{
								    if(DynamicFactions[0][fBank] < cfactionmetade)
								    {
								    cfaction=0;
									format(wstring, sizeof(wstring), "Dinheiro Recebido: 0$ [ Rank: %s ] [Balanзo Faction:%d$ ]", rank, DynamicFactions[faction][fBank]);
        							SendClientMessage(i, COLOR_WHITE, wstring);
        							format(wstring, sizeof(wstring), "A faction nem o governo te pagaram, por falta de fundos. Manifesta-te contra isto, nгo fiques parado!");
        							SendClientMessage(i, COLOR_WHITE, wstring);
        							}
        							else
        							{
        							cfaction=cfactionmetade;
				    				PlayerInfo[i][Bankc] += cfaction;
				    				DynamicFactions[PlayerInfo[i][Faction]][fBank]-=cfactionmetade;
				    				DynamicFactions[0][fBank]-=cfactionmetade;
									format(wstring, sizeof(wstring), "Dinheiro Recebido:%d$ [ Rank: %s ] [Balanзo Faction:%d$ ]", cfaction, rank, DynamicFactions[faction][fBank]);
        							SendClientMessage(i, COLOR_WHITE, wstring);
        							format(wstring, sizeof(wstring), "A faction nгo te pagou, por falta de fundos. Recebeste metade do salбrio por parte do governo.");
        							SendClientMessage(i, COLOR_WHITE, wstring);
        							}
								}
							}
						}}

Third - Car System Bug


Players are loosing vehicles that they bought..


Код:
new UniqueCarroString[MAX_PLAYERS+5][20];
new UniqueCarroEstacionar[MAX_PLAYERS+5][MAX_VEHICLES];
new UniqueCarroDono[MAX_PLAYERS+5][MAX_VEHICLES];
new UniqueCarroUser[MAX_PLAYERS+5][MAX_VEHICLES];
new UniqueCarroNumber[MAX_PLAYERS+5];

stock CarregarCarroDono(playerid)
{
	new sql[128];
	new savingstring[20];
	format(sql, sizeof(sql), "SELECT * FROM `carrodono` WHERE `player`='%d'",PlayerInfo[playerid][UniqueID]);
	mysql_query(sql);
	mysql_store_result();
//	new player = PlayerInfo[playerid][UniqueID];
	new carro;
	//UniqueCarroDono[playerid][0]=0;
	while(mysql_retrieve_row())
	{
        mysql_fetch_field_row(savingstring, "carro"); carro=strval(savingstring);

		if(PlayerInfo[playerid][CarKey1]==999)
		{
		    format(sql, sizeof(sql), "DELETE FROM `carrodono` WHERE `player`='%d' AND `carro`='%d'",PlayerInfo[playerid][UniqueID], carro);
			mysql_query(sql);
		    PlayerInfo[playerid][CarKey1]=carro;
		}
		if(PlayerInfo[playerid][CarKey2]==999)
		{
		    format(sql, sizeof(sql), "DELETE FROM `carrodono` WHERE `player`='%d' AND `carro`='%d'",PlayerInfo[playerid][UniqueID], carro);
			mysql_query(sql);
		    PlayerInfo[playerid][CarKey1]=carro;
		}
		if(PlayerInfo[playerid][CarKey3]==999)
		{
		    format(sql, sizeof(sql), "DELETE FROM `carrodono` WHERE `player`='%d' AND `carro`='%d'",PlayerInfo[playerid][UniqueID], carro);
			mysql_query(sql);
		    PlayerInfo[playerid][CarKey1]=carro;
		}
		if(PlayerInfo[playerid][CarKey4]==999)
		{
		    format(sql, sizeof(sql), "DELETE FROM `carrodono` WHERE `player`='%d' AND `carro`='%d'",PlayerInfo[playerid][UniqueID], carro);
			mysql_query(sql);
		    PlayerInfo[playerid][CarKey1]=carro;
		}
		if(PlayerInfo[playerid][CarKey5]==999)
		{
		    format(sql, sizeof(sql), "DELETE FROM `carrodono` WHERE `player`='%d' AND `carro`='%d'",PlayerInfo[playerid][UniqueID], carro);
			mysql_query(sql);
		    PlayerInfo[playerid][CarKey1]=carro;
		}
		if(PlayerInfo[playerid][CarKey6]==999)
		{
		    format(sql, sizeof(sql), "DELETE FROM `carrodono` WHERE `player`='%d' AND `carro`='%d'",PlayerInfo[playerid][UniqueID], carro);
			mysql_query(sql);
		    PlayerInfo[playerid][CarKey1]=carro;
		}
        //UniqueCarroDono[playerid][carro]=1;
	}
	mysql_free_result();
	return 1;
}

stock GuardarCarroDono(playerid)
{
	new sql[128];
	new savingstring[20];
	format(sql, sizeof(sql), "SELECT * FROM `carrodono` WHERE `player`='%d'",PlayerInfo[playerid][UniqueID]);
	mysql_query(sql);
	mysql_store_result();
	new player = PlayerInfo[playerid][UniqueID];
	new carro;
	while(mysql_retrieve_row())
	{
        mysql_fetch_field_row(savingstring, "carro"); carro=strval(savingstring);

        if(UniqueCarroDono[playerid][carro]==0)
		{
            format(sql, sizeof(sql), "DELETE FROM `carrodono` WHERE `player`='%d' AND `carro`='%d'",player, carro);
			mysql_query(sql);
		}
	}
	mysql_free_result();
 	return 1;
}

stock CarregarCarroUser(playerid)
{
	new sql[128];
	new savingstring[20];
	format(sql, sizeof(sql), "SELECT * FROM `carrouser` WHERE `player`='%d'",PlayerInfo[playerid][UniqueID]);
	mysql_query(sql);
	mysql_store_result();
	new player = PlayerInfo[playerid][UniqueID];
	new carro;
	UniqueCarroUser[playerid][0]=0;
	UniqueCarroNumber[playerid]=0;
	UniqueCarroString[playerid][1]=999;
	UniqueCarroString[playerid][2]=999;
	UniqueCarroString[playerid][3]=999;
	UniqueCarroString[playerid][4]=999;
	UniqueCarroString[playerid][5]=999;
	UniqueCarroString[playerid][6]=999;
	UniqueCarroString[playerid][7]=999;
	UniqueCarroString[playerid][8]=999;
	UniqueCarroString[playerid][9]=999;
	UniqueCarroString[playerid][10]=999;
//	UniqueCarro[player][11]=999;
//	UniqueCarro[player][12]=999;
//	UniqueCarro[player][13]=999;
//	UniqueCarro[player][14]=999;
//	UniqueCarro[player][15]=999;
//	UniqueCarro[player][16]=999;
//	UniqueCarro[player][17]=999;
//	UniqueCarro[player][18]=999;
//	UniqueCarro[player][19]=999;
//	UniqueCarro[player][20]=999;
	while(mysql_retrieve_row())
	{
        mysql_fetch_field_row(savingstring, "carro"); carro=strval(savingstring);

        UniqueCarroUser[playerid][carro]=1;
		UniqueCarroNumber[playerid]++;
  		UniqueCarroString[playerid][UniqueCarroNumber[playerid]]=carro;
	}
	mysql_free_result();
	format(sql, sizeof(sql), "SELECT * FROM `carroestacionar` WHERE `player`='%d'",PlayerInfo[playerid][UniqueID]);
	mysql_query(sql);
	mysql_store_result();
	while(mysql_retrieve_row())
	{
        mysql_fetch_field_row(savingstring, "carro"); carro=strval(savingstring);

        UniqueCarroEstacionar[playerid][carro]=1;
	}
	mysql_free_result();
	return 1;
}


stock GuardarCarroUser(playerid)
{
	new sql[128];
	new savingstring[20];
	format(sql, sizeof(sql), "SELECT * FROM `carrouser` WHERE `player`='%d'",PlayerInfo[playerid][UniqueID]);
	mysql_query(sql);
	mysql_store_result();
	new player = PlayerInfo[playerid][UniqueID];
	new carro;
	while(mysql_retrieve_row())
	{
        mysql_fetch_field_row(savingstring, "carro"); carro=strval(savingstring);

        if(UniqueCarroUser[playerid][carro]==0)
		{
            format(sql, sizeof(sql), "DELETE FROM `carrouser` WHERE `player`='%d' AND `carro`='%d'",player, carro);
			mysql_query(sql);
		}
	}
	mysql_free_result();
	format(sql, sizeof(sql), "SELECT * FROM `carroestacionar` WHERE `player`='%d'",PlayerInfo[playerid][UniqueID]);
	mysql_query(sql);
	mysql_store_result();
	while(mysql_retrieve_row())
	{
        mysql_fetch_field_row(savingstring, "carro"); carro=strval(savingstring);

        if(UniqueCarroEstacionar[playerid][carro]==0)
		{
            format(sql, sizeof(sql), "DELETE FROM `carroestacionar` WHERE `player`='%d' AND `carro`='%d'",player, carro);
			mysql_query(sql);
		}
	}
	mysql_free_result();
	return 1;
}

public CriarCarroDono(playerid, carroid)
{

	new sQuery[500];
	new player = PlayerInfo[playerid][UniqueID];
	UniqueCarroDono[playerid][carroid]=1;
 	format(sQuery, sizeof(sQuery), "INSERT INTO `carrodono` (`player`, `carro`) VALUES ('%d', '%d')", player, carroid);
  	if(!mysql_query(sQuery))
   	{
    	SendClientMessageToAll(COLOR_RED, sQuery);
		SendClientMessageToAll(COLOR_RED, "ErrorID: 15 - Problemas ao gravar no MySQL!!!");
	}
 	mysql_store_result();
  	mysql_free_result();
  	return 1;
}

public CriarCarroUser(playerid, carroid)
{

//
//**new player=PlayerInfo[playerid][UniqueID];
//****UniqueCarroUser[player][carroid]=1;
//****UniqueCarroNumber[player]++;
//****UniqueCarro[player][UniqueCarroNumber[player]]=carroid;
//****new sql[128];
//****format(sql, sizeof(sql), "INSERT INTO `carrouser` (`player`, `carro`) VALUES ('%d', '%d')",player, carroid);
//****mysql_query(sql);
//****mysql_store_result();
//****mysql_free_result();
//

	new sQuery[500];
	new player = PlayerInfo[playerid][UniqueID];


 	//if(UniquePlayerLogged[player]==1)
	//{
	UniqueCarroUser[playerid][carroid]=1;
 	UniqueCarroNumber[playerid]++;
  	new cn=UniqueCarroNumber[playerid];
   	UniqueCarroString[playerid][cn]=carroid;
	//}

 	format(sQuery, sizeof(sQuery), "INSERT INTO `carrouser` (`player`, `carro`) VALUES ('%d', '%d')", player, carroid);
  	if(!mysql_query(sQuery))
   	{
    	SendClientMessageToAll(COLOR_RED, sQuery);
		SendClientMessageToAll(COLOR_RED, "ErrorID: 16 - Problemas ao gravar no MySQL!!!");
	}
 	mysql_store_result();
  	mysql_free_result();
  	return 1;
}

public CriarCarroEstacionar(playerid, carroid)
{
//
//****new player=PlayerInfo[playerid][UniqueID];
//****UniqueCarroUser[player][carroid]=1;
//****UniqueCarroNumber[player]++;
//****UniqueCarro[player][UniqueCarroNumber[player]]=carroid;
//****new sql[128];
//****format(sql, sizeof(sql), "INSERT INTO `carrouser` (`player`, `carro`) VALUES ('%d', '%d')",player, carroid);
//****mysql_query(sql);
//****mysql_store_result();
//****mysql_free_result();
//

	new sQuery[500];
	new player = PlayerInfo[playerid][UniqueID];


 	//if(UniquePlayerLogged[player]==1)
	//{
	UniqueCarroEstacionar[playerid][carroid]=1;
	//}

 	format(sQuery, sizeof(sQuery), "INSERT INTO `carroestacionar` (`player`, `carro`) VALUES ('%d', '%d')", player, carroid);
  	if(!mysql_query(sQuery))
   	{
    	SendClientMessageToAll(COLOR_RED, sQuery);
		SendClientMessageToAll(COLOR_RED, "ErrorID: 25 - Problemas ao gravar no MySQL!!!");
	}
 	mysql_store_result();
  	mysql_free_result();
  	return 1;
}

stock EliminarCarroCenas(carroid)
{
    new sQuery[500];
   	format(sQuery, sizeof(sQuery), "DELETE FROM carrouser WHERE carro='%d'", carroid);
  	if(!mysql_query(sQuery))
   	{
    	SendClientMessageToAll(COLOR_RED, sQuery);
		SendClientMessageToAll(COLOR_RED, "ErrorID: 26 - Problemas ao gravar no MySQL!!!");
	}
	format(sQuery, sizeof(sQuery), "DELETE FROM carrodono WHERE carro='%d'", carroid);
  	if(!mysql_query(sQuery))
   	{
    	SendClientMessageToAll(COLOR_RED, sQuery);
		SendClientMessageToAll(COLOR_RED, "ErrorID: 26 - Problemas ao gravar no MySQL!!!");
	}
	format(sQuery, sizeof(sQuery), "DELETE FROM carroestacionar WHERE carro='%d'", carroid);
  	if(!mysql_query(sQuery))
   	{
    	SendClientMessageToAll(COLOR_RED, sQuery);
		SendClientMessageToAll(COLOR_RED, "ErrorID: 26 - Problemas ao gravar no MySQL!!!");
	}
	return 1;
}
When someone buy a car, it uses CriarCarroDono and CriarCarroUser. When player logout it uses GuardarCarroUser and GuardarCarroDono. When player login it uses CarregarCarroUser and CarregarCarroDono. When players sells a vehicle, it uses EliminarCarroCenas.




Please help me, thanks!
Reply
#2

Someone help me?
Reply
#3

Try to put #define GivePlayerWeapon DarArmaPlayer at the top of your code.
Reply
#4

Quote:
Originally Posted by Aguylera
Посмотреть сообщение
Try to put #define GivePlayerWeapon DarArmaPlayer at the top of your code.
It didn't work.
Reply
#5

Up. Up.
Reply
#6

Up. Up.
Reply
#7

Up. Up.
Reply
#8

Up. Up.
Reply
#9

This
pawn Код:
public RemovePlayerWeapon(playerid, weaponid)
{
    new plyWeapons[12] = 0;
    new plyAmmo[12] = 0;
    for(new sslot = 0; sslot != 12; sslot++)
    {
        new wep, ammo;
        GetPlayerWeaponData(playerid, sslot, wep, ammo);
        if(wep != weaponid && ammo != 0) GetPlayerWeaponData(playerid, sslot, plyWeapons[sslot], plyAmmo[sslot]);
    }
    ArmaTimerPause[playerid]=1;
    ResetPlayerWeapons(playerid);
    for(new sslot = 0; sslot != 12; sslot++)
    {
        if(plyAmmo[sslot] != 0)
        {
            GivedPlayerWeapon[playerid][plyWeapons[sslot]]=1;
            GivePlayerWeapon(playerid, plyWeapons[sslot], plyAmmo[sslot]);
        }
    }
    return 1;
}
To this

pawn Код:
public RemovePlayerWeapon(playerid, weaponid)
{
    new plyWeapons[12] = 0;
    new plyAmmo[12] = 0;
    for(new sslot = 0; sslot != 12; sslot++)
    {
        new wep, ammo;
        GetPlayerWeaponData(playerid, sslot, wep, ammo);
        if(wep != weaponid && ammo != 0) GetPlayerWeaponData(playerid, sslot, plyWeapons[sslot], plyAmmo[sslot]);
    }
    ArmaTimerPause[playerid]=1;
    ResetPlayerWeapons(playerid);
    for(new sslot = 0; sslot != 12; sslot++)
    {
        if(plyAmmo[sslot] != 0)
        {
            GivePlayerWeapon(playerid, plyWeapons[sslot], plyAmmo[sslot]);
        }
    }
    GivedPlayerWeapon[playerid][weaponid]=0;// or switch it to 1 if doesnt work either
    return 1;
}
Should fix it, you were setting the variable value to the weapon slot instead of the weapon id.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)