06.03.2015, 07:13
Im not too sure with what i messed up while making this function. Ive built many other functions the exact same way but have never had this issue.
Function
Error:
[03:43:55] [debug] Run time error 5: "Invalid memory access"
[03:43:55] [debug] AMX backtrace:
[03:43:55] [debug] #0 00017f2c in ?? () from TN.amx
[03:43:55] [debug] #1 00018140 in public cmd_addgasstation (0x00000000, 0x0001ffd from TN.amx
[03:43:55] [debug] #2 native CallLocalFunction () [00472ad0] from samp-server.exe
[03:43:55] [debug] #3 000088a0 in public OnPlayerCommandText (0x00000000, 0x0001ff7c) from TN.amx
Function
pawn Код:
enum TN_gsInfo
{
Float:X,
Float:Y,
Float:Z,
Price,
Name[30],
Pickup,
MapIcon,
Text3D:Label
}
new TN_gsData[][TN_gsInfo];
stock GetNextStationID()
{
for (new i=1; i < 200; i++) if (!TN_gsData[i][Price]) return i;
return 0;
}
CMD:addgasstation(playerid,params[])
{
TN_OWNER;
new Float:aX,Float:aY,Float:aZ,price,name[30];
GetPlayerPos(playerid,aX,aY,aZ);
if(sscanf(params,"is[30]",price,name)) return SendClientMessage(playerid,COLOR_RED,"Usage: /AddGasStation [Price] [Station Name]");
if(price <= 0) return SendClientMessage(playerid,COLOR_RED,"Station price must be at least one dollar!");
new id = GetNextStationID();
if(id == 0) return SendClientMessage(playerid,COLOR_RED,"Error creating gas station!");
new String[300];
format(String,sizeof(String),"INSERT INTO `gasstations` (`id`,`x`,`y`,`z`,`price`,`name`) VALUES ('%d','%f','%f','%f','%d','%s')",id,aX,aY,aZ,price,name);
QUERY(String);
TN_gsData[id][Price] = price;
TN_gsData[id][X] = aX;
TN_gsData[id][Y] = aY;
TN_gsData[id][Z] = aZ;
format(TN_gsData[id][Name],30,"%s",name);
TN_gsData[id][Pickup] = CreateDynamicPickup(1318, 23, TN_gsData[id][X], TN_gsData[id][Y], TN_gsData[id][Z], 0, 0, -1);
format(String,sizeof(String),"Welcome to the %s Gas Station!\nPress and hold SPACE to fill your vehicle!",TN_gsData[id][Name]);
TN_gsData[id][Label] = CreateDynamic3DTextLabel(String, GAS_LABEL_COLOR, TN_gsData[id][X], TN_gsData[id][Y], TN_gsData[id][Z]+0.75, 20, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, true, 0, 0, -1);
TN_gsData[id][MapIcon] = CreateDynamicMapIcon(0.0, 0.0, 0.0, 56, 0, 0, 0, INVALID_PLAYER_ID, 500.0);
printf("FUELSYSTEM INC: Created and Loaded The %s Gas Station!", TN_gsData[id][Name]);
Streamer_Update(playerid);
return 1;
}
[03:43:55] [debug] Run time error 5: "Invalid memory access"
[03:43:55] [debug] AMX backtrace:
[03:43:55] [debug] #0 00017f2c in ?? () from TN.amx
[03:43:55] [debug] #1 00018140 in public cmd_addgasstation (0x00000000, 0x0001ffd from TN.amx
[03:43:55] [debug] #2 native CallLocalFunction () [00472ad0] from samp-server.exe
[03:43:55] [debug] #3 000088a0 in public OnPlayerCommandText (0x00000000, 0x0001ff7c) from TN.amx