[HELP] Help me please
#1

Hi,

I'm in need of explanation on saving PlayerInfo variables like (Jailed = 1 or Jailed = 0, FirstSpawn =1, FirstSpawn = 0 and saving that into a file)

And then read it back again when the player spawns again.

Also I'm in need of explanation on how to get gametext on a timer.

Thank you,
KnooL


Codes:
pawn Код:
Command_(jail)
{
if (help)
{
Text_Send(playerid, "JAIL_HELP");
Text_SendFormat(playerid, "JAIL_HELP1", "jail");
}
if (PlayerInfo[player][Jailed] == 1)
{
Text_Send(playerid, "ALREADY_JAILED");
}
else
{
if(sscanf(params, "uzi", player, kbreason, timen))
{
Text_Send(playerid, "JAIL_HELP");
Text_SendFormat(playerid, "JAIL_HELP1", "jail");
}
else if (IsPlayerConnected(player))
{
timern = SetTimer("JailTime", timen, 0);
GetPlayerName(player, giveplayername, sizeof(giveplayername));
GetPlayerName(playerid, sendername, sizeof(sendername));
Text_SendFormat(player, "YOU_GOT_JAILED", ReturnPlayerName(playerid), playerid, kbreason);
PlayerInfo[player][Jailed] = 1;
OnPlayerJailed(player);
}
}
if (!IsPlayerConnected(player))
{
Text_Send(playerid, "NOT_CONNECTED");
}
return 1;
}
pawn Код:
public JailTime()
{
for(new i=0; i<MAX_PLAYERS; i++)
{
  if (PlayerInfo[i][Jailed] == 1)
  {
    SetPlayerInterior(i, 6);
    SetPlayerPos(i, 266.9272,78.6098,1001.0391);
    SetPlayerFacingAngle(i, 266.9169);
    TogglePlayerControllable(i, 1);
}
}
}
Works without errors or warnings. Haven't tested it out yet in-game, the only thing I need is how to get gametext on how much jail time is left.

Thanks in advance.
Reply
#2

Alright, first, the GameText thingy. You'll need a function to handle the GameText showing, you could use something like this:

pawn Код:
forward DelayedGameText(playerid, string[], time, style);
public DelayedGameText(playerid, string[], time, style)
{
  GameTextForPlayer(playerid, string[], time, style);
}
It's not very hard to understand, basicly we are just creating another function that will be doing the same as GameTextForPlayer, but it is public, which means that can be called with a timer. Once we have this, we will have to use SetTimerEx to call a function and pass parameters to it.
First read what SetTimerEx is here forward https://sampwiki.blast.hk/wiki/SetTimerEx .

So would need to add a line like:
pawn Код:
SetTimerEx("DelayedGameText", "isii", playerid, string, 5000, 3);
But right before that, you will need to format the 'string' variable to include the jail time left. You can do it with something like this:
pawn Код:
new string[128];
format(string, sizeof(string), "You have %d time left in jail", JailLeft);
Changing JailLeft to whatever is the variable holding the jail time left.

Regarding file saving, dini is a good file saving handler, I used it a lot of times and is very easy and makes your code easy to read. Search for it.
[/pawn]
Reply
#3

Thank you for responding on my thread and your help!

I managed to clear all errors and warnings, I will tell you if it worked out when I'm going to test it.
I'm going to start with DINI now.
Reply
#4

Quote:
Originally Posted by Zamaroht
Changing JailLeft to whatever is the variable holding the jail time left.
This didn't work out well, could you give me an example?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)