command(arrest, playerid,params[])
{
new string[128];
new ID;
new time;
if (sscanf(params, "ud", ID, time))
{
if(Factions[Player[playerid][Faction]][CommandTypes] == 1 || Factions[Player[playerid][Faction]][CommandTypes] == 3)
{
SendClientMessage(playerid, COLOR_GREY, "SYNTAX: /arrest [playerid/name] [minutes]");
}
else
{
RemoveTextMessage(playerid);
TextDrawShowForPlayer(playerid, Text:CantCommand);
SetTimerEx("RemoveTextMessage", 3500, false, "d", playerid);
}
}
if(GetDistanceBetweenPlayers(playerid,ID) > 4)
{
format(string,sizeof(string),"%s(%d) is too far away. You cannot reach him to arrest him.",RPName(ID),ID);
SendClientMessage(playerid,-1,string);
return 1;
}
if(GetDistanceBetweenPlayers(playerid,ID) <= 4)
{
ResetPlayerWeapons(ID);
Player[ID][Arrest] = 1;
Player[ID][PrisonTime] = time * 60;
SetPlayerSpecialAction(ID, SPECIAL_ACTION_NONE);
format(string, sizeof(string), "> You've arrested %s for %d days at San Andreas Prison.", RPName(ID), time);
SendClientMessage(playerid, SPECIALORANGE, string);
format(string, sizeof(string), "> %s has you arrested for %d days at San Andreas Prison.", RPName(playerid), time);
SendClientMessage(ID, SPECIALORANGE, string);
}
return 1;
}
C'mon man... What's it doing...
Don't just post up code expecting people to fix it for you by just looking at it. Tell us what is actually happening, and don't say "It doesn't work"... It should at least be returning some output. |
command(arrest, playerid,params[])
{
new ID, time;
if(sscanf(params, "ud", ID, time))
{
if(Factions[Player[playerid][Faction]][CommandTypes] == 1 || Factions[Player[playerid][Faction]][CommandTypes] == 3)
SendClientMessage(playerid, COLOR_GREY, "SYNTAX: /arrest [playerid/name] [minutes]");
else
{
RemoveTextMessage(playerid);
TextDrawShowForPlayer(playerid, Text:CantCommand);
SetTimerEx("RemoveTextMessage", 3500, false, "d", playerid);
}
return 1;
}
if(!IsPlayerConnected(ID) || ID == INVALID_PLAYER_ID)
return SendClientMessage(playerid, -1, "That player does not exist."); // Change the message to your own preference. Do not continue without checking for a valid player ID.
new string[90];
if(GetDistanceBetweenPlayers(playerid, ID) > 4.0)
{
format(string, sizeof(string), "%s(%d) is too far away. You cannot reach him to arrest him.", RPName(ID), ID);
SendClientMessage(playerid, -1, string);
}
else
{
ResetPlayerWeapons(ID);
Player[ID][Arrest] = 1;
Player[ID][PrisonTime] = time * 60;
SetPlayerSpecialAction(ID, SPECIAL_ACTION_NONE);
format(string, sizeof(string), "> You've arrested %s for %d days at San Andreas Prison.", RPName(ID), time);
SendClientMessage(playerid, SPECIALORANGE, string);
format(string, sizeof(string), "> %s has arrested you for %d days at San Andreas Prison.", RPName(playerid), time);
SendClientMessage(ID, SPECIALORANGE, string);
}
return 1;
}
command(arrest, playerid,params[])
{
new ID, time, string[90];
if(sscanf(params, "ud", ID, time))//If the playerid did NOT enter the correct parameters..
{
//If the playerid did NOT enter the correct parameters..
if(Factions[Player[playerid][Faction]][CommandTypes] == 1 || Factions[Player[playerid][Faction]][CommandTypes] == 3)//If player PASSES Faction check..
{
SendClientMessage(playerid, COLOR_GREY, "SYNTAX: /arrest [playerid/name] [minutes]");//Send the playerid a usage message, as they did NOT enter the correct parameters..
}
else//Else if the player FAILED Faction check..
{
//Do this..
RemoveTextMessage(playerid);
TextDrawShowForPlayer(playerid, Text:CantCommand);
SetTimerEx("RemoveTextMessage", 3500, false, "d", playerid);
}
return 1;//This is CRITICAL. You need to tell the server to STOP here as the process is now done. Otherwise the server will just keep going(down the script)..
}
else//Else the playerid DID enter the correct parameters..
{
if(!IsPlayerConnected(ID) || ID == INVALID_PLAYER_ID)//If you have NPC's, I suggest you use !IsPlayerNPC(playerid) on this line..
{
return SendClientMessage(playerid, -1, "That player does not exist.");//Notify the playerid that the targetid does NOT exist..
}
if(GetDistanceBetweenPlayers(playerid, ID) > 4.0)//If the playerid EXISTS(online) and is MORE THAN 4 Metres away(or too far away)..
{
format(string, sizeof(string), "%s(%d) is too far away. You cannot reach him to arrest him.", RPName(ID), ID);//Notify the playerid..
SendClientMessage(playerid, -1, string);
return 1;//AGAIN this is CRITICAL(and was missing) as you need to tell the server when to STOP, otherwise it will CONTINUE(down the script)..
}
else//Else the playerid IS WITHIN or EQUAL TO 4 Metres from the targetid(ID)...
{
//Execute the arrest..
ResetPlayerWeapons(ID);
Player[ID][Arrest] = 1;
Player[ID][PrisonTime] = time * 60;
SetPlayerSpecialAction(ID, SPECIAL_ACTION_NONE);
format(string, sizeof(string), "> You've arrested %s for %d days at San Andreas Prison.", RPName(ID), time);
SendClientMessage(playerid, SPECIALORANGE, string);
format(string, sizeof(string), "> %s has arrested you for %d days at San Andreas Prison.", RPName(playerid), time);
SendClientMessage(ID, SPECIALORANGE, string);
//I don't see a function that SENDS the player to Prison.. you may need to add this(unless Player[ID][Arrest] is checked somewhere else and THEN sends the targetid to Prison)
}
}
return 1;
}
The Arrest/prisontime will be not setted in the MYSQL after using this command can you maybe explain me why?
|
else { ResetPlayerWeapons(ID); Player[ID][Arrest] = 1; Player[ID][PrisonTime] = time * 60; SetPlayerSpecialAction(ID, SPECIAL_ACTION_NONE); format(string, sizeof(string), "> You've arrested %s for %d days at San Andreas Prison.", RPName(ID), time); SendClientMessage(playerid, SPECIALORANGE, string); format(string, sizeof(string), "> %s has arrested you for %d days at San Andreas Prison.", RPName(playerid), time); SendClientMessage(ID, SPECIALORANGE, string); }
Because in this segment of code, nothing does anything with MySQL.
It should however be saving something, around the StatsSaving function usually. Otherwise the code could go in this area Код:
else { ResetPlayerWeapons(ID); Player[ID][Arrest] = 1; Player[ID][PrisonTime] = time * 60; SetPlayerSpecialAction(ID, SPECIAL_ACTION_NONE); format(string, sizeof(string), "> You've arrested %s for %d days at San Andreas Prison.", RPName(ID), time); SendClientMessage(playerid, SPECIALORANGE, string); format(string, sizeof(string), "> %s has arrested you for %d days at San Andreas Prison.", RPName(playerid), time); SendClientMessage(ID, SPECIALORANGE, string); } |