20.10.2011, 15:39
heey all,
Mademan made a code for my server for weapon dealer to change prices from weapons each slot.
But when i change price of 5 slots or higher it will crash my samp.
Code:
I made code for showweapons to a player. Its a test command for the shop:
Its something with this i think:
Can someone help me fix this pls?
Mademan made a code for my server for weapon dealer to change prices from weapons each slot.
But when i change price of 5 slots or higher it will crash my samp.
Code:
Код:
dcmd_setprice(playerid,params[]) { new string[128]; new price; new dealerid = GetPVarInt(playerid, "arm1"); //new foodid = GetPVarInt(playerid, "food1"); if(sscanf(params, "i", price)) { //SendClientMessage(playerid,COLOR_RED,"USAGE: /setprice (Amount)"); //return 1; } if(IsSpawned[playerid] != 1) { SendClientMessage(playerid,COLOR_RED,"You must be alive and spawned in order to be able to use this command."); return 1; } if(gTeam[playerid] != TEAM_MEDIC && gTeam[playerid] != TEAM_CARFIX && gTeam[playerid] != TEAM_DRIVER&& gTeam[playerid] != TEAM_GUNDEL && gTeam[playerid] != TEAM_FOOD) { SendClientMessage(playerid,COLOR_RED,"You cannot use this command with your class/skill."); return 1; } if(gTeam[playerid] == TEAM_GUNDEL) { new slot, price2; new Total[700],str1[256],str2[256]; if(sscanf(params, "dd", slot, price2)) { SendClientMessage(playerid,COLOR_RED,"USAGE: /setprice (slot) (price)"); return 1; } if(slot < 1 || slot >= sizeof(WeaponPrices[])) { SendClientMessage(playerid,COLOR_RED,"Invalid slot"); return 1; } if(price2 > 50000 || price2 < 1000) { SendClientMessage(playerid,COLOR_RED,"Please enter an amount between $1000 and $50000."); return 1; } WeaponPrices[playerid][slot] = price2; format(string,sizeof(string),"You have set weapon slot %d price to $%d", slot, price2); SendClientMessage(playerid,COLOR_LIGHTBLUE,string); format(str1,sizeof(str1),"~n~~n~~n~~n~ ~n~~b~500 ammo $%d~n~~b~500 ammo $%d~n~~b~500 ammo $%d~n~~b~500 ammo $%d~n~~y~~b~500 ammo $%d",WeaponPrices[dealerid][1],WeaponPrices[dealerid][2],WeaponPrices[dealerid][3],WeaponPrices[dealerid][4],WeaponPrices[dealerid][5]); format(str2,sizeof(str2),"~b~500 ammo $%d~n~~b~500 ammo $%d~n~~b~500 ammo $%d~n~~b~500 ammo $%d~n~~y~~b~500 ammo $%d~n~~y~~b~500 ammo $%d~n~~y~~b~500 ammo $%d~n~",WeaponPrices[dealerid][6],WeaponPrices[dealerid][7],WeaponPrices[dealerid][8],WeaponPrices[dealerid][9],WeaponPrices[dealerid][10],WeaponPrices[dealerid][11],WeaponPrices[dealerid][12]); format(Total,sizeof(Total),"%s %s",str1,str2); TextDrawSetString(TextDraw5,Total); return 1; } return 1; }
Код:
dcmd_showweapons(playerid,params[]) { new string[128]; new str3[128]; new ID; new Total[700],str1[256],str2[256]; new slot, price2; WeaponPrices[playerid][slot] = price2; if(sscanf(params, "u", ID)) { SendClientMessage(playerid,COLOR_RED,"USAGE: /showweapons (Player Name/ID)"); return 1; } if(IsKidnapped[playerid] == 1) { SendClientMessage(playerid,COLOR_RED,"You are kidnapped. You cannot use this command."); return 1; } if(IsSpawned[playerid] != 1) { SendClientMessage(playerid,COLOR_RED,"You must be alive and spawned in order to be able to use this command."); return 1; } if(gTeam[playerid] != TEAM_GUNDEL) { SendClientMessage(playerid,COLOR_RED,"Only Weapon Dealers can show people their weapons for sale."); return 1; } if(!IsPlayerConnected(ID)) { format(string,sizeof(string),"The player ID (%d) is not connected to the server. You cannot give them weapons",ID); SendClientMessage(playerid,COLOR_RED,string); return 1; } if(GetDistanceBetweenPlayers(playerid,ID) > 4) { format(string,sizeof(string),"%s(%d) is too far away. You cannot reach him to show him weapons.",PlayerName(ID),ID); SendClientMessage(playerid,COLOR_RED,string); return 1; } /*if(gTeam[ID] == TEAM_GUNDEL) { SendClientMessage(playerid,COLOR_RED,"You cannot give other Weapon Dealers weapons .. Im sure they have plenty."); return 1; }*/ /*if(playerid == ID) { SendClientMessage(playerid,COLOR_RED,"You cannot give yourself weapons. Go to Ammunation to get some."); return 1; }*/ if(IsSpawned[ID] != 1) { format(string,sizeof(string),"%s(%d) is not spawned. You cannot give dead people weapons ..",PlayerName(ID),ID); SendClientMessage(playerid,COLOR_RED,string); return 1; } /*if(CalledForWeaponDealer[ID] == 0) { SendClientMessage(playerid,COLOR_RED,"They have not called for a weapon dealer. You cannot give them weapons."); return 1; }*/ //if(arm1==1) //{ //GivePlayerMoney(playerid,SkillPrice[playerid]); //TextDrawHideForPlayer(ID,TextDraw4[playerid]); //} if(GetDistanceBetweenPlayers(playerid,ID) <= 4) { TextDrawShowForPlayer(ID,TextDraw4); TextDrawShowForPlayer(ID,TextDraw7); //TextDrawShowForPlayer(ID,TextDraw5); format(str1,sizeof(str1),"~n~~n~~n~~n~ ~n~~b~500 ammo $%d~n~~b~500 ammo $%d~n~~b~500 ammo $%d~n~~b~500 ammo $%d~n~~y~~b~500 ammo $%d",WeaponPrices[ID][1],WeaponPrices[ID][2],WeaponPrices[ID][3],WeaponPrices[ID][4],WeaponPrices[ID][5]); format(str2,sizeof(str2)," ~b~500 ammo $%d~n~~b~500 ammo $%d~n~~b~500 ammo $%d~n~~b~500 ammo $%d~n~~y~~b~500 ammo $%d~n~~y~~b~500 ammo $%d~n~~y~~b~500 ammo $%d~n~",WeaponPrices[ID][6],WeaponPrices[ID][7],WeaponPrices[ID][8],WeaponPrices[ID][9],WeaponPrices[ID][10],WeaponPrices[ID][11],WeaponPrices[ID][12]); format(Total,sizeof(Total),"%s %s",str1,str2); TextDrawSetString(TextDraw5,Total); TextDrawShowForPlayer(ID,TextDraw5); format(str3,sizeof(str3),"~g~%s's Weaponshop",PlayerName(ID)); TextDrawSetString(TextDraw6,str3); TextDrawShowForPlayer(ID,TextDraw6); armshop[ID]=1; SetPVarInt(ID, "arm1", playerid);if(IsPlayerConnected(playerid)==1) return 1; } return 1; }
Код:
format(str1,sizeof(str1),"~n~~n~~n~~n~ ~n~~b~500 ammo $%d~n~~b~500 ammo $%d~n~~b~500 ammo $%d~n~~b~500 ammo $%d~n~~y~~b~500 ammo $%d",WeaponPrices[dealerid][1],WeaponPrices[dealerid][2],WeaponPrices[dealerid][3],WeaponPrices[dealerid][4],WeaponPrices[dealerid][5]); format(str2,sizeof(str2),"~b~500 ammo $%d~n~~b~500 ammo $%d~n~~b~500 ammo $%d~n~~b~500 ammo $%d~n~~y~~b~500 ammo $%d~n~~y~~b~500 ammo $%d~n~~y~~b~500 ammo $%d~n~",WeaponPrices[dealerid][6],WeaponPrices[dealerid][7],WeaponPrices[dealerid][8],WeaponPrices[dealerid][9],WeaponPrices[dealerid][10],WeaponPrices[dealerid][11],WeaponPrices[dealerid][12]); format(Total,sizeof(Total),"%s %s",str1,str2); TextDrawSetString(TextDraw5,Total);