Run time error 5: "Invalid memory access" -
Wolfmaster - 09.09.2012
Hi all!
I have a big problem, but I can't fix it. These commands are crashed my server often. :/
I'm using this crashdetect plugin: https://sampforum.blast.hk/showthread.php?tid=262796
----------------------------
The first bug:
Код:
[debug] Run time error 5: "Invalid memory access"
[debug] AMX backtrace:
[debug] #0 0001964c in public OnPlayerCommandText (playerid=9, cmdtext[]=@0x000a2850 "") at D:\Program Files (x86)\Rockstar Games\server1\filterscripts\ladmin4v2.pwn:2275
Line 2275 on ladmin4v2:
dcmd(register, 8, cmdtext); (Under the OnPlayerCommandText)
The register command:
Код:
dcmd_register(playerid,params[])
{
if (PlayerInfo[playerid][LoggedIn] == 1) return SendClientMessage(playerid,red,"ACCOUNT: You are already logged in!");
if (strlen(params) < 4 || strlen(params) > 20) return SendClientMessage(playerid,red,"ACCOUNT: The password lenght is incorrect!");
if(!strlen(params)) return SendClientMessage(playerid, red, "ACCOUNT: USAGE: /register password");
if (udb_Create(PlayerName2(playerid),params))
{
new Rfile[256],name[MAX_PLAYER_NAME], Rtmp3[100];
GetPlayerName(playerid,name,sizeof(name)); format(Rfile,sizeof(Rfile),"/ladmin/users/%s.sav",udb_encode(name));
dini_Set(Rfile,"password",params);
GetPlayerIp(playerid,Rtmp3,100);
dini_Set(Rfile,"ip",Rtmp3);
dUserSetINT(PlayerName2(playerid)).("registered",1);
new strdate[20], year,month,day;
getdate(year, month, day);
format(strdate, sizeof(strdate), "%d/%d/%d",year,month,day);
dini_Set(Rfile,"RegisteredDate",strdate);
dUserSetINT(PlayerName2(playerid)).("loggedin",1);
dUserSetINT(PlayerName2(playerid)).("banned",0);
dUserSetINT(PlayerName2(playerid)).("level",0);
dUserSetINT(PlayerName2(playerid)).("LastOn",0);
dUserSetINT(PlayerName2(playerid)).("money",0);
dUserSetINT(PlayerName2(playerid)).("kills",0);
dUserSetINT(PlayerName2(playerid)).("deaths",0);
dUserSetINT(PlayerName2(playerid)).("hours",0);
dUserSetINT(PlayerName2(playerid)).("minutes",0);
dUserSetINT(PlayerName2(playerid)).("seconds",0);
dUserSetINT(PlayerName2(playerid)).("score",0);
PlayerInfo[playerid][LoggedIn] = 1;
PlayerInfo[playerid][Registered] = 1;
SendClientMessage(playerid, green, "ACCOUNT: Successful registration!");
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
}
return 1;
}
----------------------------
The second bug:
Код:
[debug] Run time error 5: "Invalid memory access"
[debug] AMX backtrace:
[debug] #0 00009f34 in public OnPlayerCommandText (playerid=9, cmdtext[]=@0x000226f0 "") at D:\Program Files (x86)\Rockstar Games\server1\filterscripts\FS.pwn:242
Line 242 on FS.pwn:
dcmd(contract,8,cmdtext);
The command:
Код:
dcmd_contract(playerid,params[])
{
new tmp[128],tmp2[256],idx,val;
new id = strval(params);
tmp=strtok(params,idx);
tmp2=strtok(params,idx);
id=strval(tmp);
val=strval(tmp2);
if(!strlen(tmp) || !strlen(tmp2) || !IsNumeric(tmp) || !IsNumeric(tmp2)) {
return SendClientMessage(playerid,COLOR_YELLOW,"USAGE: /contract [id] [/contract price = more than 1000$]");
}
else if(!IsPlayerConnected(id)) {
return SendClientMessage(playerid,COLOR_RED,"Incorrect ID!");
}
else if(val>GetPlayerMoney(playerid) || val<1000){
return SendClientMessage(playerid,COLOR_RED,"You don't have 1000$! (the minimum price!)");
}
else if(playerid==id) {
return SendClientMessage(playerid,COLOR_RED,"Try it an other ID! (It's you!)");
}
else if(verdij[id]==1) {
return SendClientMessage(playerid,COLOR_RED,"You have already called the hitman!");
}
else {
new String[255], pName[MAX_PLAYER_NAME], kName[MAX_PLAYER_NAME];
bMoney[id]=val;
verdij[id]=1;
GetPlayerName(playerid,kName,sizeof(kName));
GetPlayerName(id,pName,sizeof(pName));
format(String,sizeof(String),"[CONTRACT]: %s called a hitman. Target person: %s [Price: $ %d]",kName,pName,val);
SendClientMessageToAll(COLOR_YELLOW,String);
GivePlayerMoney(playerid,-val);
}
return 1;
}
----------------------------
And the third problem
The error code:
Код:
[debug] Run time error 5: "Invalid memory access"
[debug] AMX backtrace:
[debug] #0 00032b40 in public OnPlayerCommandText (playerid=9, cmdtext[]=@0x001664b0 "") at D:\Program Files (x86)\Rockstar Games\server1\gamemodes\Gamemode.pwn:5008
The command:
Код:
dcmd_tazer(playerid, params[])
{
new Float:X, Float:Y, Float:Z, player1;
if(sscanf(params,"u", player1)) return SendClientMessage(playerid, 0xFF0000AA, "[ERROR] USAGE: /tazer [id]");
if(player1 == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000AA, "[ERROR] This player is offline!");
if(IsCuffed[player1] == 1) return SendClientMessage(playerid, 0xFF0000AA, "[ERROR] This player already shocked!");
if(gTeam[playerid] != TEAM_COP && gTeam[playerid] != SWAT)
{
SendClientMessage(playerid,COLOR_RED,"You are not a Police Unit!");
return 1;
}
GetPlayerPos(player1, X, Y, Z);
if(IsPlayerInRangeOfPoint(playerid, 20.0, X, Y, Z))
{
TogglePlayerControllable(player1, false);
IsTazed[player1] = 1;
GameTextForPlayer(player1, "~r~ Shocked!", 4000, 4);
SetTimerEx("tazertimer", 7000, false, "u", player1);
SendClientMessage(playerid, 0xFF0000AA, "{00FF00}[SUCCESSFUL SHOCKED!]");
SendClientMessage(player1, 0xFF0000AA, "{FF0000}You have shocked by a Police Unit!");
}
return 1;
}
----------------------------
Somebody and ideas?
Re: Run time error 5: "Invalid memory access" -
Wolfmaster - 11.09.2012
Nobody can help me?
Re: Run time error 5: "Invalid memory access" -
Caupo - 04.04.2014
If anyone still might look into this thread, then I just encountered that error on me and I debugged like a hour or so. Cause I had lots of functions which depended on each other nested in each other and so. And I finally catched the reason why it gives that error.
I had one function where I wanted to return string from one of my functions which also returned string from function. So yeah, returning string from function can cause an issue like this. So yeah to fix this, before you return string, you have to get your string which you want to return, formatted in some string variable, and then you have to return the string variable. (It also might be my own incompetent by not knowing maybe it's written in PAWNs refenrece that you can't do that like this but yeah...)
So yeah maybe it helps someone in the future. Im going to copy and paste that case to other topics too related to that error. Maybe it helps some fellow scripters on the path.