[help] command makes the server drops.
#1

Hello, I am not able to run this command, every time you run the command in the game the server drops, someone could show me where I am missing ? Please. sorry bad english google XD.http://pastebin.com/m70fbaab9
Код:
  if(strcmp(cmd,"/sellgun",true)==0)
  {
    if(IsPlayerConnected(playerid))
	  {
		  if (PlayerInfo[playerid][pJob] != 9)
			{
			  SendClientMessage(playerid,COLOR_GREY," You are not a Arms Dealer !");
			  return 1;
			}
			new x_weapon[256],levell[MAX_PLAYERS],levelll[MAX_PLAYERS],levellll[MAX_PLAYERS];
			new weapon[MAX_PLAYERS],ammo[MAX_PLAYERS];
			new sellMats[MAX_PLAYERS];
			tmp = strtok(cmdtext, idx);
			new skillevel = PlayerInfo[playerid][pArmsSkill];
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GREEN, "________________________________________________");
				SendClientMessage(playerid, COLOR_WHITE, "*** Sell Guns ***");
				SendClientMessage(playerid, COLOR_GREY, "USAGE: /sellgun [playerid/PartOfName] [weaponname]");
				SendClientMessage(playerid, COLOR_GREEN, "________________________________________________");
				return 1;
			}
			giveplayerid = ReturnUser(tmp);
			if (IsPlayerConnected(giveplayerid))
			{
			  if (ProxDetectorS(5.0, playerid, giveplayerid))
			  {
			    if(giveplayerid != INVALID_PLAYER_ID)
			    {
					  x_weapon = strtok(cmdtext, idx);
					  if(!strlen(x_weapon))
					  {
						  SendClientMessage(playerid, COLOR_GREEN, "________________________________________________");
				      SendClientMessage(playerid, COLOR_WHITE, "*** Sell Guns ***");
              if(PlayerInfo[playerid][pArmsSkill] >= 0)
					    {
							SendClientMessage(playerid, COLOR_GREY, " Golfclub(25) Shovel(25) Poolcue(50) Cane(25) Sdpistol(100) Shotgun(200)");
							}
	            if(PlayerInfo[playerid][pArmsSkill] >= 225)
					    {
							SendClientMessage(playerid, COLOR_GREY, " Baseballbat(50) Flowers(25) Mp5(500)");
							}
					    if(PlayerInfo[playerid][pArmsSkill] >= 375)
					    {
							SendClientMessage(playerid, COLOR_GREY, " Deagle(2000) Rifle(1000)");
							}
					    if(PlayerInfo[playerid][pArmsSkill] >= 550)
					    {
							SendClientMessage(playerid, COLOR_GREY, " Katana(50) Ak47(3500)");
							}
							if(PlayerInfo[playerid][pArmsSkill] >= 750)
					    {
							SendClientMessage(playerid, COLOR_GREY, " M4(4000) Sniper(6500) Aspas12(6500)");
							}
						  SendClientMessage(playerid, COLOR_GREEN, "________________________________________________");
						  return 1;
					  }
				  }
				  if (strcmp(x_weapon, "golfclub", true, strlen(x_weapon)) == 0)
				  {
            weapon[giveplayerid] = 2; ammo[giveplayerid] = 1;
            sellMats[playerid] = 25;
						levell[playerid] = 0;
				  	PlayerInfo[giveplayerid][pGun0] = 2; PlayerInfo[giveplayerid][pAmmo0] = 1;
				  	levelll[playerid] = 100; levellll[playerid] = 101;
				  }
				  else if (strcmp(x_weapon, "baseballbat", true, strlen(x_weapon)) == 0)
				  {
				  	weapon[giveplayerid] = 5; ammo[giveplayerid] = 1;
				  	sellMats[playerid] = 50; levell[playerid] = 101;
				  	PlayerInfo[giveplayerid][pGun0] = 5; PlayerInfo[giveplayerid][pAmmo0] = 1;
				  	levelll[playerid] = 225; levellll[playerid] = 226;
			  	}
			  	else if (strcmp(x_weapon, "shovel", true, strlen(x_weapon)) == 0)
			  	{
			  		weapon[giveplayerid] = 6; ammo[giveplayerid] = 1;
			  		sellMats[playerid] = 50; levell[playerid] = 0;
			   		PlayerInfo[giveplayerid][pGun0] = 6; PlayerInfo[giveplayerid][pAmmo0] = 1;
			  		levelll[playerid] = 100; levellll[playerid] = 101;
			  	}
			  	else if (strcmp(x_weapon, "poolcue", true, strlen(x_weapon)) == 0)
			  	{
			  		weapon[giveplayerid] = 7; ammo[giveplayerid] = 1;
			  		sellMats[playerid] = 50; levell[playerid] = 0;
			  		PlayerInfo[giveplayerid][pGun0] = 7; PlayerInfo[giveplayerid][pAmmo0] = 1;
			  		levelll[playerid] = 100; levellll[playerid] = 101;
			  	}
			  	else if (strcmp(x_weapon, "flowers", true, strlen(x_weapon)) == 0)
			  	{
			  		weapon[giveplayerid] = 14; ammo[giveplayerid] = 1;
			  		sellMats[playerid] = 25; levell[playerid] = 101;
			  		PlayerInfo[giveplayerid][pGun1] = 14; PlayerInfo[giveplayerid][pAmmo1] = 1;
			  		levelll[playerid] = 225; levellll[playerid] = 226;
			  	}
			  	else if (strcmp(x_weapon, "cane", true, strlen(x_weapon)) == 0)
			  	{
			  		weapon[giveplayerid] = 15; ammo[giveplayerid] = 1;
			  		sellMats[playerid] = 25; levell[playerid] = 0;
			  		PlayerInfo[giveplayerid][pGun1] = 15; PlayerInfo[giveplayerid][pAmmo1] = 1;
			  		levelll[playerid] = 100; levellll[playerid] = 101;
			  	}
			  	else if (strcmp(x_weapon, "katana", true, strlen(x_weapon)) == 0)
			  	{
			  		weapon[giveplayerid] = 8; ammo[giveplayerid] = 1;
			  		sellMats[playerid] = 50; levell[playerid] = 375;
			  		PlayerInfo[giveplayerid][pGun0] = 8; PlayerInfo[giveplayerid][pAmmo0] = 1;
			  		levelll[playerid] = 550; levellll[playerid] = 551;
			  	}
			  	else if (strcmp(x_weapon, "sdpistol", true, strlen(x_weapon)) == 0)
			  	{
			  		weapon[giveplayerid] = 23; ammo[giveplayerid] = 100000;
			  		sellMats[playerid] = 100; levell[playerid] = 0;
			  		PlayerInfo[giveplayerid][pGun2] = 23; PlayerInfo[giveplayerid][pAmmo2] = 100000;
			  		levelll[playerid] = 100; levellll[playerid] = 101;
			  	}
			  	else if (strcmp(x_weapon, "deagle", true, strlen(x_weapon)) == 0)
			  	{
			  		weapon[giveplayerid] = 24; ammo[giveplayerid] = 100000;
			  		sellMats[playerid] = 2000; levell[playerid] = 226;
			  		PlayerInfo[giveplayerid][pGun2] = 24; PlayerInfo[giveplayerid][pAmmo2] = 100000;
			  		levelll[playerid] = 375; levellll[playerid] = 376;
			  	}
			  	else if (strcmp(x_weapon, "mp5", true, strlen(x_weapon)) == 0)
			  	{
			  		weapon[giveplayerid] = 29; ammo[giveplayerid] = 100000;
			  		sellMats[playerid] = 500; levell[playerid] = 100;
			   		PlayerInfo[giveplayerid][pGun4] = 29; PlayerInfo[giveplayerid][pAmmo4] = 100000;
			  		levelll[playerid] = 225; levellll[playerid] = 226;
			  	}
			  	else if (strcmp(x_weapon, "shotgun", true, strlen(x_weapon)) == 0)
			  	{
			  		weapon[giveplayerid] = 25; ammo[giveplayerid] = 100000;
			   		sellMats[playerid] = 200; levell[playerid] = 0;
			  		PlayerInfo[giveplayerid][pGun3] = 25; PlayerInfo[giveplayerid][pAmmo3] = 100000;
			  		levelll[playerid] = 100; levellll[playerid] = 101;
			  	}
		  		else if (strcmp(x_weapon, "ak47", true, strlen(x_weapon)) == 0)
		  		{
		  			weapon[giveplayerid] = 30; ammo[giveplayerid] = 100000;
		  			sellMats[playerid] = 3500; levell[playerid] = 375;
		  			PlayerInfo[giveplayerid][pGun5] = 30; PlayerInfo[giveplayerid][pAmmo5] = 100000;
		  			levelll[playerid] = 550; levellll[playerid] = 551;
		  		}
		  		else if (strcmp(x_weapon, "m4", true, strlen(x_weapon)) == 0)
		  		{
		  			weapon[giveplayerid] = 31; ammo[giveplayerid] = 100000;
		  			sellMats[playerid] = 4000; levell[playerid] = 550;
		  			PlayerInfo[giveplayerid][pGun5] = 31; PlayerInfo[giveplayerid][pAmmo5] = 100000;
		  			levelll[playerid] = 750; levellll[playerid] = 751;
		  		}
		  		else if (strcmp(x_weapon, "sniper", true, strlen(x_weapon)) == 0)
		  		{
		  			weapon[giveplayerid] = 34; ammo[giveplayerid] = 100000;
		  			sellMats[playerid] = 6500; levell[playerid] = 550;
		  			PlayerInfo[giveplayerid][pGun6] = 34; PlayerInfo[giveplayerid][pAmmo6] = 100000;
		  			levelll[playerid] = 750; levellll[playerid] = 751;
		  		}
			  	else if (strcmp(x_weapon, "aspas12", true, strlen(x_weapon)) == 0)
			  	{
			  		weapon[giveplayerid] = 27; ammo[giveplayerid] = 100000;
			  		sellMats[playerid] = 6500; levell[playerid] = 550;
			  		PlayerInfo[giveplayerid][pGun3] = 27; PlayerInfo[giveplayerid][pAmmo3] = 100000;
			  		levelll[playerid] = 750; levellll[playerid] = 751;
			  	}
			  	else if (strcmp(x_weapon, "rifle", true, strlen(x_weapon)) == 0)
			  	{
			  		weapon[giveplayerid] = 33; ammo[giveplayerid] = 100000;
			  		sellMats[playerid] = 1000; levell[playerid] = 100;
			  		PlayerInfo[giveplayerid][pGun6] = 33; PlayerInfo[giveplayerid][pAmmo6] = 100000;
			  		levelll[playerid] = 225; levellll[playerid] = 226;
			  	}
          else
			  	{
			  	  SendClientMessage(playerid,COLOR_GREY," Invalid Weapon name!");
			  	  return 1;
			  	}
			  	if(PlayerInfo[playerid][pMats] < sellMats[playerid])
			  	{
			  	  SendClientMessage(playerid,COLOR_GREY," Not enough Materials for that Weapon!");
			  	  return 1;
			  	}
			  	if(skillevel > levell[playerid] && skillevel < levelll[playerid] || skillevel > levellll[playerid])
			  	{
			  	  SendClientMessage(playerid,COLOR_GREY," level is not sufficient for this Weapon!");
			  	  return 1;
			  	}
			  	if(PlayerInfo[playerid][pMiserPerk] > 0)
			  	{
			  	  new skilvl = 2 * PlayerInfo[playerid][pMiserPerk];
			  	  new matts = sellMats[playerid] / 100;
			  	  sellMats[playerid] -= (matts)*(skilvl);
			  	}
		  		PlayerInfo[playerid][pArmsSkill] ++;
          if(PlayerInfo[playerid][pArmsSkill] == 50)
		  		{ SendClientMessage(playerid, COLOR_YELLOW, "* You Arms Dealer is now Level 2."); }
	        else if(PlayerInfo[playerid][pArmsSkill] == 100)
		  		{ SendClientMessage(playerid, COLOR_YELLOW, "* You Arms Dealer is now Level 3."); }
		  		else if(PlayerInfo[playerid][pArmsSkill] == 200)
				  { SendClientMessage(playerid, COLOR_YELLOW, "* You Arms Dealer is now Level 4."); }
				  else if(PlayerInfo[playerid][pArmsSkill] == 400)
				  { SendClientMessage(playerid, COLOR_YELLOW, "* You Arms Dealer is now Level 5."); }
				  GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
				  GetPlayerName(playerid, sendername, sizeof(sendername));
				  PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
				  SendClientMessage(playerid, COLOR_GRAD1, string);
				  format(string, sizeof(string), " You have recieved a %s from %s.", x_weapon, sendername);
				  SendClientMessage(giveplayerid, COLOR_GRAD1, string);
				  PlayerPlaySound(giveplayerid, 1052, 0.0, 0.0, 0.0);
 	        format(string, sizeof(string), "* %s created a Gun from Materials, and hands it to %s.", sendername ,giveplayer);
				  ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				  PlayerInfo[playerid][pMats] -= sellMats[playerid];
  		    GivePlayerWeapon(giveplayerid,weapon[giveplayerid],ammo[giveplayerid]);
  		    weapon[giveplayerid] = 0;
  		    ammo[giveplayerid] = 0;
				}
				else
				{
					SendClientMessage(playerid, COLOR_GRAD1, " Your too far away.");
					return 1;
				}
			}
			else
			{
				format(string, sizeof(string), " %d is not an active player.", giveplayerid);
				SendClientMessage(playerid, COLOR_GRAD1, string);
			}
		}
		return 1;
	}
Reply
#2

"PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
SendClientMessage(playerid, COLOR_GRAD1, string);
format(string, sizeof(string), " You have recieved a %s from %s.", x_weapon, sendername);"

The line 205 on pastebin, has "SendClientMessage(playerid, COLOR_GRAD1, string);" but I see nothing which actually puts text into the string.

So it's sending an undefined string which is crashing it.

Try removing that line and then trying it.
Reply
#3

thanks friend, it was a mistake but so small, I do not understand, thank you for your attention. thank you very much.
Reply
#4

Quote:
Originally Posted by Lineax
thanks friend, it was a mistake but so small, I do not understand, thank you for your attention. thank you very much.
could you pls post the right code here, cause i got a problem like you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)