Jailment player Tutorial!
#1

The most new scripters doesn't know it, and the most other tutorials aren't complete...
So here a COMPLETE jailment function!
You just need to edit it to your type of cmd....

What you need to have/know?
  • You need player files to save things in!
  • pJail[playerid] = 0; // player is not jailed
  • pJail[playerid] = 1; // player is jailed.
Add on TOP
Quote:

new JailLeft[MAX_PLAYERS];
new pJail[MAX_PLAYERS];
#define JAIL_TIME_FOR_PLAYER 30
forward JailTime();

Add just somewhere in the script...
Quote:

public JailTime()
{
new string[128];
for(new i=0; i<MAX_PLAYERS; i++)
{
if (pJail[i] == 1)
{
if(IsPlayerConnected(i))
{
if(JailLeft[i] <= 0)
{
SendClientMessage(i,0xDAA520FF,"You have been released from jail");
SpawnPlayer(i);
pJail[i]=0;

}
else
{

format(string, sizeof(string), "You have %d time left in jail", JailLeft[i]);
SendClientMessage(i,0xDAA520FF,string);
JailLeft[i]--;
SetPlayerPos(i, 266.9272,78.6098,1001.0391);
SetPlayerFacingAngle(i, 266.9169);
TogglePlayerControllable(i, 1);
}
}
}
}
return 1;
}

Here comes the /jail <id> <time> command
Quote:

CMD:jail(playerid, params[])
{
new tmp[256],tmp2[256],tmp3[256],Index,CUSTOM_TIME;
tmp = Xstrtok(params,Index);
tmp2 = strtok(params,Index);
tmp3 = strtok(params,Index);
format(tmp2,sizeof(tmp2),"%s",params[strlen(tmp) + strlen(tmp3)]);
format(tmp3,sizeof(tmp3),"%s",params[strlen(tmp) + strlen(tmp2)]);
printf( " string %s value %d",tmp3,strval(tmp3));
if(strlen(tmp2)<3)
{
format(tmp2,sizeof(tmp2),"Unknown Reason");
}
CUSTOM_TIME = strval(tmp3);
if(IsPlayerConnected(strval(tmp)) && IsNumeric(tmp))
{
new ID=strval(tmp);
if (pJail[ID] == 1)
{
return SendClientMessage(playerid, 0xFFFFFFFF, "ALREADY_JAILED");
}
SetPlayerInterior(ID, 6);
SetPlayerPos(ID, 266.9272,78.6098,1001.0391);
SetPlayerFacingAngle(ID, 266.9169);
TogglePlayerControllable(ID, 1);
SendClientMessage(ID, 0xFFFFFFFF, "YOU_GOT_JAILED");
pJail[ID] = 1;
JailLeft[ID]=CUSTOM_TIME;
}
else SendClientMessage(playerid, 0xFFFFFFFF, "NOT_CONNECTED");
return 1;
}

Here comes the /unjail <id> command
Quote:

CMD:unjail(playerid, params[])
{
new tmp[256], tmp2[256],Index;
tmp = strtok(params,Index);
tmp2 = strtok(params,Index);

pJail[strval(params)] = strval(tmp2);

new string[ 128 ];
new vname[ 24 ];
GetPlayerName( strval(params), vname, sizeof( vname ));
format( string, sizeof( string ), "You have unjailed %s.", vname);
SendClientMessage( playerid, 0xFFFF00FF, string );

new string2[ 128 ];
new sname[ 24 ];
GetPlayerName( playerid, sname, sizeof( sname ));
format( string2, sizeof( string2 ), "You have been unjailed by %s.", sname);
SendClientMessage( playerid, 0xFFFF00FF, string2 );
return 1;
}

Hope this will help you guys out!
Reply
#2

Quote:
Originally Posted by screw
The most new scripters doesn't know it, and the most other tutorials are complete...
So here a COMPLETE jailment function!
You just need to edit it to your type of cmd....

What you need to have/know?
  • You need player files to save things in!
  • pJail[playerid] = 0; // player is not jailed
  • pJail[playerid] = 1; // player is jailed.
Add on TOP
Quote:

new JailLeft[MAX_PLAYERS];
new pJail[MAX_PLAYERS];
#define JAIL_TIME_FOR_PLAYER 30
forward JailTime();

Enter just somewhere in the script...
Quote:

public JailTime()
{
new string[128];
for(new i=0; i<MAX_PLAYERS; i++)
{
if (pJail[i] == 1)
{
if(IsPlayerConnected(i))
{
if(JailLeft[i] <= 0)
{
SendClientMessage(i,0xDAA520FF,"You have been released from jail");
SpawnPlayer(i);
pJail[i]=0;

}
else
{

format(string, sizeof(string), "You have %d time left in jail", JailLeft[i]);
SendClientMessage(i,0xDAA520FF,string);
JailLeft[i]--;
SetPlayerPos(i, 266.9272,78.6098,1001.0391);
SetPlayerFacingAngle(i, 266.9169);
TogglePlayerControllable(i, 1);
}
}
}
}
return 1;
}

Her comes the /jail <id> <time> command
Quote:

CMD:jail(playerid, params[])
{
new tmp[256],tmp2[256],tmp3[256],Index,CUSTOM_TIME;
tmp = Xstrtok(params,Index);
tmp2 = strtok(params,Index);
tmp3 = strtok(params,Index);
format(tmp2,sizeof(tmp2),"%s",params[strlen(tmp) + strlen(tmp3)]);
format(tmp3,sizeof(tmp3),"%s",params[strlen(tmp) + strlen(tmp2)]);
printf( " string %s value %d",tmp3,strval(tmp3));
if(strlen(tmp2)<3)
{
format(tmp2,sizeof(tmp2),"Unknown Reason");
}
CUSTOM_TIME = strval(tmp3);
if(IsPlayerConnected(strval(tmp)) && IsNumeric(tmp))
{
new ID=strval(tmp);
if (pJail[ID] == 1)
{
return SendClientMessage(playerid, 0xFFFFFFFF, "ALREADY_JAILED");
}
SetPlayerInterior(ID, 6);
SetPlayerPos(ID, 266.9272,78.6098,1001.0391);
SetPlayerFacingAngle(ID, 266.9169);
TogglePlayerControllable(ID, 1);
SendClientMessage(ID, 0xFFFFFFFF, "YOU_GOT_JAILED");
pJail[ID] = 1;
JailLeft[ID]=CUSTOM_TIME;
}
else SendClientMessage(playerid, 0xFFFFFFFF, "NOT_CONNECTED");
return 1;
}

Here come the /unjail <id> command
Quote:

CMD:unjail(playerid, params[])
{
new tmp[256], tmp2[256],Index;
tmp = strtok(params,Index);
tmp2 = strtok(params,Index);

pJail[strval(params)] = strval(tmp2);

new string[ 128 ];
new vname[ 24 ];
GetPlayerName( strval(params), vname, sizeof( vname ));
format( string, sizeof( string ), "You have unjailed %s.", vname);
SendClientMessage( playerid, 0xFFFF00FF, string );

new string2[ 128 ];
new sname[ 24 ];
GetPlayerName( playerid, sname, sizeof( sname ));
format( string2, sizeof( string2 ), "You have been unjailed by %s.", sname);
SendClientMessage( playerid, 0xFFFF00FF, string2 );
return 1;
}

Hope this will help you guys out!
Nice..
But shouldn't it be
dcmd_jail(playerid, params[]) instead of CMD:jail(playerid, params[]) ?
Reply
#3

That's ZCMD :P
Reply
#4

I could be anything there are many ways to make commands. So make me happy and post more ways to do it. Easy for new players.
Reply
#5

pawn Код:
CMD:jail(playerid, params[])
{
  new tmp[256],tmp2[256],tmp3[256],Index,CUSTOM_TIME;
Ew. You should probably revise on a few tutorials before posting any yourself. You've made a BILLION variables throughout the script that could be simplified to practically 1. Sorry, I know you're trying to help out, but this is probably a snippet from godfather.
Reply
#6

Use [PAWN] tags. Also, did you just copy that straight out of another persons script?
Reply
#7

Quote:
Originally Posted by [HiC
TheKiller ]
Use [PAWN] tags. Also, did you just copy that straight out of another persons script?
Jup, i didnt say it was perfect and also not that it was fully mine, i also got helped with it too, so there may be some errors,... but for me it works so...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)