CMD:pcar(playerid,params[]){
for(new i=0; i < MAX_HOUSES_PER_PLAYER; i++){
if(!IsPlayerInRangeOfPoint(playerid,8.0,hinfo[pinfo[playerid][houses][i]][enter_pos_x],hinfo[pinfo[playerid][houses][i]][enter_pos_y],hinfo[pinfo[playerid][houses][i]][enter_pos_z]))continue;
GetPlayerPos(playerid,hinfo[pinfo[playerid][houses][i]][cpark_pos_x],hinfo[pinfo[playerid][houses][i]][cpark_pos_y],hinfo[pinfo[playerid][houses][i]][cpark_pos_z]);
new query[300];
mysql_format(db_connect,query,sizeof(query),"UPDATE samp_tabella_houses SET cpark_x ='%f', cpark_y ='%f', cpark_z='%f' WHERE ID ='%i'",hinfo[pinfo[playerid][houses][i]][cpark_pos_x],hinfo[pinfo[playerid][houses][i]][cpark_pos_y],hinfo[pinfo[playerid][houses][i]][cpark_pos_z],pinfo[playerid][houses][i]);
SendClientMessage(playerid,-1,"{FF0000}//{FFFFFF}system: You have parked your vehicle near your house");
}
return 1;
}
CMD:scar(playerid,params[]){
if(tmp_car_house_spawned[playerid]!=1){
for(new i=0; i<MAX_HOUSES_PER_PLAYER;i++){
if(!IsPlayerInRangeOfPoint(playerid,10.0,hinfo[pinfo[playerid][houses][i]][enter_pos_x],hinfo[pinfo[playerid][houses][i]][enter_pos_y],hinfo[pinfo[playerid][houses][i]][enter_pos_z]))continue;
AddStaticVehicleEx(pinfo[playerid][vehicle_id][0],hinfo[pinfo[playerid][houses][i]][cpark_pos_x],hinfo[pinfo[playerid][houses][i]][cpark_pos_y],hinfo[pinfo[playerid][houses][i]][cpark_pos_z],0.0,0,0,10);
tmp_car_house_spawned[playerid]=1;
break;
}
}
return 1;
}
Sometimes OnPlayerCommandText and zcmd encounter eachother, make sure you deleted the OnPlayerCommandText call-back, that should do.
|
stock GetFreeBankSlot(playerid)
{
for(new i = 0; i < MAX_BANK_ACCOUNTS; i++)
{
if(BankInformation[playerid][i][BankSlotUsed])
continue;
else
return i;
}
return -1;
}
By any chance do all your other commands work excluding these two you have provided for us to help you with?
Note: It may be caused by the loops in your command, I ran into a problem doing it like you have before so i just put them into a stock and ran it from there, Check the example below. pawn Код:
|
forward scar(playerid);
public scar(playerid){
if(tmp_car_house_spawned[playerid]!=1){
for(new i=0; i<MAX_HOUSES_PER_PLAYER;i++){
if(!IsPlayerInRangeOfPoint(playerid,10.0,hinfo[pinfo[playerid][houses][i]][enter_pos_x],hinfo[pinfo[playerid][houses][i]][enter_pos_y],hinfo[pinfo[playerid][houses][i]][enter_pos_z]))continue;
AddStaticVehicleEx(pinfo[playerid][vehicle_id][0],hinfo[pinfo[playerid][houses][i]][cpark_pos_x],hinfo[pinfo[playerid][houses][i]][cpark_pos_y],hinfo[pinfo[playerid][houses][i]][cpark_pos_z],0.0,0,0,10);
tmp_car_house_spawned[playerid]=1;
break;
}
}
return 1;
}
CMD:scar(playerid,params[]){
scar(playerid);
return 1;
}
The likely explanation if that code is running is some kind of OOB error on your array this is a very common problem and usually very easy to fix make sure you have crashdetect plugin that will let you know if it really is the problem. Also don't use the stock modifier when creating functions that is used generally when making libraries where a function may or may not be used and serves no purpose but to obfuscate your code.
https://sampforum.blast.hk/showthread.php?tid=262796 My hunch at this time is an OOB here hinfo[pinfo[playerid][houses][i]] you probably have a default value in that array which is causing an OOB. |
[22:54:39] [debug] Run time error 4: "Array index out of bounds" [22:54:39] [debug] Accessing element at negative index -1 [22:54:39] [debug] AMX backtrace: [22:54:39] [debug] #0 00026aec in public cmd_pcar (0, 8479092) from testproject.amx [22:54:39] [debug] #1 native CallLocalFunction () from samp-server.exe [22:54:39] [debug] #2 0000619c in public OnPlayerCommandText (0, 8479068) from testproject.amx
if(pinfo[playerid][houses][i] == -1) continue;
Because you need to do this in your loop.
pawn Код:
|