SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 04/06/2012, 09:02 PM   #1
MarkoN
Big Clucker
 
MarkoN's Avatar
 
Join Date: May 2012
Posts: 175
Reputation: 24
Default unjail only for ID 0 problem.

pawn Code:
if(!strcmp(cmdtext, "/jail", true, 5))
{
  if(Admin[playerid] >= 1 )
  {
  SendClientMessage(playerid, COLOR_RED, "WARNING : AFTER JAILING A PLAYER UNJAIL HIM AFTER 2 MIN");
  if(!strlen(cmdtext[6]))
  {
    SendClientMessage(playerid, COLOR_RED, "Usage /jail [playerid]");
    return 1;
  }
  new ID = strval(cmdtext[6]);
  new strv[170];
  if(IsPlayerConnected(ID))
  {

    format(strv, 170, "You have been jailed");
    SendClientMessage(ID,COLOR_ORANGE, strv);
    SetPlayerPos(ID, 264.8763,78.9862,1001.0390);
    SetPlayerInterior(ID, 6);
  }
  }
  else
  {
    SendClientMessage(playerid,COLOR_RED,"You are not an admin!");
  }
  return 1;

}
    if(!strcmp(cmdtext, "/unjail", true, 7))
{
  if(Admin[playerid] >= 1 )
  {
  if(!strlen(cmdtext[8]))
  {
    SendClientMessage(playerid, COLOR_RED, "Usage : /unjail [playerid]");
    return 1;
  }
  new ID = strval(cmdtext[8]);
  new strv[171];
  if(IsPlayerConnected(ID))
  {

    format(strv, 171, "You have been Unjailed");
    SendClientMessage(ID,COLOR_ORANGE, strv);
    SetPlayerPos(ID, 1553.4637,-1675.6656,16.1953);
    SetPlayerInterior(ID, 0);
  }
  }
  else
  {
    SendClientMessage(playerid,COLOR_RED,"You are not an admin!");
  }
  return 1;

}

Jail works just fine, but /unjail only works for ID 0 .
MarkoN is offline   Reply With Quote
Old 04/06/2012, 09:36 PM   #2
Sandiel
Huge Clucker
 
Sandiel's Avatar
 
Join Date: May 2012
Location: SA-MP Forums. Pawn Level: Master. Occupation: Scripter.
Posts: 384
Reputation: 45
Default Re: unjail only for ID 0 problem.

For this you will be needing ZCMD, and sscanf. ZCMD is far more better than strcmp, seriously.
pawn Code:
COMMAND:unjail(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 1)
    {
        new targetid;
        if(!sscanf(params, "u", targetid))
        {
            if(IsPlayerConnected(targetid))
            {
                if(IsPlayerInRangeOfPoint(targetid, 3, jailX, jailY, jailZ))
                {
                    SetPlayerPos(targetid, somewhereX, somewhereY, somewhereZ);
                    new pName[MAX_PLAYER_NAME], aName[MAX_PLAYER_NAME], str[128];
                    GetPlayerName(playerid, aName, sizeof(aName));
                    GetPlayerName(targetid, pName, sizeof(pName));
                    format(str, sizeof(str), "AdmCmd: %s has been released by %s from his jail time", pName, aName);
                    SendClientMessageToAll(COLOR_RED, str);
                }
            }
        }
    }
    return 1;
}
__________________
My work:
[FS]New unique DJ Job, suitable for everyone[UPDATED]
[FS]SmartChecker System v1.3[UPDATED]
WILL CODE FOR LEAGUE OF LEGENDS SKINS.


All of the work made by SandieL is registered and fully licensed by Creative Common, this work is copyrighted
Sandiel is offline   Reply With Quote
Old 04/06/2012, 09:39 PM   #3
park4bmx
High-roller
 
park4bmx's Avatar
 
Join Date: Dec 2009
Location: Samokov,Bulgaria
Posts: 2,357
Reputation: 236
Default Re: unjail only for ID 0 problem.

All characters from a string count !
pawn Code:
if(!strlen(cmdtext[7))
Try that instead of 8
reason
Becouse you have selected the string after the 8 character it leave you with nothing!
So it retrieves it as ID 0
Becouse 0 = nothing
park4bmx is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Help] Unjail NotoriousMOB Help Archive 3 16/11/2010 05:55 PM
Unprison and Unjail Problem Pixeli Help Archive 5 02/10/2010 08:32 AM
[COMANDO] Unjail Bruno da Silva Português/Portuguese 4 28/03/2010 11:56 PM
/unjail Lia Help Archive 3 24/09/2009 11:20 PM


All times are GMT. The time now is 01:56 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.