10.01.2010, 16:48
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?
Add just somewhere in the script...
Here comes the /jail <id> <time> command
Here comes the /unjail <id> command
Hope this will help you guys out!
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.
Quote:
new JailLeft[MAX_PLAYERS]; new pJail[MAX_PLAYERS]; #define JAIL_TIME_FOR_PLAYER 30 forward JailTime(); |
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; } |
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; } |
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; } |