15.10.2016, 07:48
Hey guys. I'm working on two different parts of script and I'm having issues with them both. One is a /want command and the other is wanting a killer on death.
Want command SOMETIMES works I don't know the parameters of what it works but sometimes it does but most of the time when I type the correct usage. /want 0 6 Test I get return 0. But sometimes it'll work.
This is my debug code for the warn command.
Here is the want code.
The other part is on player death. I want to want the person who killed the player +1 wanted level if they aren't 'oskined' however. The issue is. That it will only want players that are in an existing org so their OrgID won't be equal to -1. So basically; If players OrgID == 3 they will get wanted for killing player, but if OrgID == -1 (Default) they won't get wanted.
Want command SOMETIMES works I don't know the parameters of what it works but sometimes it does but most of the time when I type the correct usage. /want 0 6 Test I get return 0. But sometimes it'll work.
This is my debug code for the warn command.
Код:
[08:26:14] [debug] Run time error 4: "Array index out of bounds" [08:26:14] [debug] Attempted to read/write array element at negative index -1 [08:26:14] [debug] AMX backtrace: [08:26:14] [debug] #0 001539f0 in public cmd_want (1, 24698196) from vR.amx [08:26:14] [debug] #1 native CallLocalFunction () from samp03svr [08:26:14] [debug] #2 000008a8 in public OnPlayerCommandText (1, 24698124) from vR.amx
PHP код:
CMD:want(playerid,params[])
{
new id,lvl,reason[32],string[128],org;
new org1=PlayerInfo[playerid][OrgID];
org=PlayerInfo[id][OrgID];
if(PlayerInfo[playerid][Rules] == 0) return SendClientMessage(playerid, COLOR_RED, "You need to accept rules using /rules!");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"Error: Player is not online");
if(PlayerInfo[playerid][OrgID] == -1) return SendClientMessage(playerid,COLOR_RED,"Error: You aren't in an organization!");
if(sscanf(params, "dds[32]", id,lvl,reason)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /want [PlayerID] [Wanted Level] [Reason]");
if(PlayerInfo[id][pInJail] == 1) return SendClientMessage(playerid,COLOR_RED,"Error: this player is in jail");
if(oInfo[org1][Type] != 1) return SendClientMessage(playerid,COLOR_RED,"Error: Not Law");
if(GetPVarInt(playerid,"Oskin") == 0) return SendClientMessage(playerid,COLOR_RED,"You are not on Duty!");
if(LoggedIn[id] == 0) return SendClientMessage(playerid, COLOR_RED, "Error: Player hasn't logged in.");
if(GetPVarInt(id,"spawned") == 0) return SendClientMessage(playerid,COLOR_RED,"Error: Player not spawned");
if(GetPVarInt(id,"Oskin") == 1 && oInfo[org][Type]==1) return SendClientMessage(playerid,COLOR_RED,"Error: You can't want on duty officers");
if(id == playerid) return SendClientMessage(playerid,COLOR_RED,"Error: You can't want yourself!");
if(lvl < 0 || lvl >6) return SendClientMessage(playerid,COLOR_RED,"Error: Invalid Wanted Level");
if(IsPlayerConnected(id))
{
SetPlayerWantedLevel(id,lvl);
PlayerInfo[id][WantedLvl]=lvl;
format(string,sizeof(string),"%s's wanted level has been set to %d by %s, Reason: %s",GetName(id),lvl,GetName(playerid),reason);
if(lvl == 0)
{
format(string,sizeof(string)," %s's wanted level has been unset by %s",GetName(id),GetName(playerid));
SendClientMessageToAll(COLOR_WHITE,string);
}
else
{
SendClientMessageToAll(COLOR_LIGHTBLUE,string);
}
}
return 1;
}
PHP код:
public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid == INVALID_PLAYER_ID)
{
new ce=cell_ref[playerid];
PlayerInfo [playerid] [pSkin] = GetPlayerSkin(playerid);
SetPVarInt(playerid,"spawned",0);
ResetPlayerWeapons(playerid);
SetPVarInt(playerid,"Weps",0);
SaveAccountStats(playerid);
GameTextForPlayer(playerid,"~r~~h~WASTED",8000,1);
PlayerTextDrawHide(playerid, SpeedoText[playerid]);
SendDeathMessageEx(playerid, killerid, reason);
SetPVarInt(playerid, "Dead", 1);
TextDrawHideForPlayer(playerid,txtTimeDisp);
PlayerTextDrawHide(playerid, TxtZones[playerid]);
SetPlayerWantedLevel(playerid,0);
if(IsPlayerInAnyVehicle(playerid))
{
PlayerTextDrawHide(playerid, SpeedoText[playerid]);
}
PlayerInfo[playerid][WantedLvl]=0;
if(gPlayerUsingLoopingAnim[playerid])
{
gPlayerUsingLoopingAnim[playerid] = 0;
TextDrawHideForPlayer(playerid,txtAnimHelper);
}
GetPlayerClosestHospital(playerid);
SetSpawnInfo(playerid, NO_TEAM, GetPlayerSkin(playerid), PlayerInfo[playerid][pXPos],PlayerInfo[playerid][pYPos],PlayerInfo[playerid][pZPos],PlayerInfo[playerid][pAPos], 0, 0, 0, 0, 0, 0);
if(GetPVarInt(playerid,"Jailed") == 1)
{
SetSpawnInfo(playerid, NO_TEAM,42,cellInfo[ce][cellx],cellInfo[ce][celly],cellInfo[ce][cellz],cellInfo[ce][cella], 0, 0, 0, 0, 0, 0);
SetPlayerInterior(playerid,5);
SetPlayerWantedLevel(playerid,0);
PlayerInfo[playerid][WantedLvl]=0;
}
}
if(IsPlayerInAnyVehicle(playerid))
{
PlayerTextDrawHide(playerid, SpeedoText[playerid]);
}
new org;
new ce=cell_ref[playerid];
org=PlayerInfo[killerid][OrgID];
PlayerInfo [playerid][pSkin] = GetPlayerSkin(playerid);
SetPVarInt(playerid,"spawned",0);
ResetPlayerWeapons(playerid);
SetPVarInt(playerid,"Weps",0);
GameTextForPlayer(playerid,"~r~~h~WASTED",10000,1);
SendDeathMessageEx(playerid, killerid, reason);
SetPVarInt(playerid, "Dead", 1);
TextDrawHideForPlayer(playerid,txtTimeDisp);
PlayerTextDrawHide(playerid, TxtZones[playerid]);
PlayerTextDrawHide(playerid, SpeedoText[playerid]);
if(gPlayerUsingLoopingAnim[playerid])
{
gPlayerUsingLoopingAnim[playerid] = 0;
TextDrawHideForPlayer(playerid,txtAnimHelper);
}
if(GetPVarInt(killerid,"Jailed") == 0)
{
new string[100];
if(GetPlayerWantedLevel(killerid) == 6)
{
format(string,sizeof(string),"[CRIME]%s has murdered %s, and remains a highly wanted player, Wanted Level:%d",GetName(killerid),GetName(playerid),PlayerInfo[killerid][WantedLvl]);
SendClientMessageToAll(COLOR_LIGHTBLUE,string);
}
else
{
if(oInfo[org][Type] == 1 && GetPVarInt(killerid,"Oskin") == 0) return 1;
SetPlayerWantedLevel(killerid, GetPlayerWantedLevel(killerid) + 1);
PlayerInfo[killerid][WantedLvl]=GetPlayerWantedLevel(killerid);
format(string, sizeof(string), "[CRIME] %s has been Wanted for the murder of %s,Wanted Level:%d",GetName(killerid),GetName(playerid),PlayerInfo[killerid][WantedLvl]);
SendClientMessageToAll(COLOR_LIGHTBLUE,string);
}
}else
{
new string[100];
format(string,sizeof(string),"[JAIL]%s's sentence has been extended due to the murder of %s in prison",GetName(killerid),GetName(playerid));
SendClientMessageToAll(COLOR_YELLOW,string);
KillTimer(JailTimer[killerid]);
PlayerInfo[killerid][pInJailTime] += 2;
format(string,sizeof(string),"Your time has been extended due to your crimes within Prison, New Time:%d Minutes",PlayerInfo[killerid][pInJailTime]);
SendClientMessage(killerid,COLOR_YELLOW,string);
JailTimer[killerid]= SetTimerEx("UnjailTimer",60000,false,"ii",killerid,PlayerInfo[killerid][pInJailTime]);
}

