24.06.2012, 23:11
Hello there.
I haven't seen any of your code, so I can't say what variables you are using to store data on the player (e.g. jail time, number of escape attempts), so I shall be writing code that you will have to modify yourself, but it will tell you what parts will need to go where.
I can't find the topic on DCMD, and I haven't used it myself, so for now I shall be writing the command how it would normally appear under "OnPlayerCommandText" since it has no parameters.
Make sure to read it all:
I haven't seen any of your code, so I can't say what variables you are using to store data on the player (e.g. jail time, number of escape attempts), so I shall be writing code that you will have to modify yourself, but it will tell you what parts will need to go where.
I can't find the topic on DCMD, and I haven't used it myself, so for now I shall be writing the command how it would normally appear under "OnPlayerCommandText" since it has no parameters.
Make sure to read it all:
pawn Код:
public OnPlayerCommandText(playerid,cmdtext[]){
if(!strcmp(cmdtext,"/Escape",true)){
//If the player is not in jail, stop processing the command
if( Is Player In Jail == 0){
return SendClientMessage(playerid,0xFF0000FF,"You are not in jail.");
}
//If the player has already failed to escape from jail 2 times, stop processing the command
if( Escape Attempts >=2){
return SendClientMessage(playerid,0xFF0000FF,"You have already failed to escape from jail twice!");
}
//When the player is unjailed/connects to the server, you will need to set the variable for escape attempts to 0
//Give the player a 1 in 4 chance of escaping (25%)
new chance=random(4);
//If the random function returns a value of 1 (returns values between 0-3: https://sampwiki.blast.hk/wiki/Random)
if(chance==1){
//The player has escaped jail
Player Jail Time = 0;
SetPlayerWantedLevel(playerid,6);
GameTextForPlayer(playerid,"You have escaped from jail!~n~~r~Run!",5000,4);
SetPlayerPos(playerid,x,y,z);//Set their position to outside the jail/police station
SetPlayerInterior(playerid,0);
}
else {
//The player failed to escape jail
GameTextForPlayer(playerid,"~w~You ~r~failed~w~ to escape from jail!",5000,4);
Escape Attempts++;
}
return 1;
}
return 0;
}