format(string, sizeof(string), "[BREAKING NEWS] The suspect %s has successfully rob the money bank", GetPlayerNameEx(playerid));
format(string, sizeof(string), "[BREAKING NEWS] The suspect ID 0 NAME has successfully rob the money bank", GetPlayerNameEx(playerid));
public robtimer(playerid)
{
if(RobberBusted[playerid] == 1)
{
SendClientMessageToAll(COLOR_GREEN, "[BREAKING NEWS]: Bank Robberry Failed! Suspect has been BUSTED!");
SendClientMessage(playerid, COLOR_YELLOW, "You were busted by the POLICE, Bank Robbery Fail!");
RobberBusted[playerid] = 0;
pBankRobbing[playerid] = 0;
return 1;
}
else if(RobberBusted[playerid] == 2)
{
SendClientMessageToAll(COLOR_RED, "[BREAKING NEWS]: Bank Robberry failed! Suspect has been eliminated ((Leaving/Timeout at server))");
RobberBusted[playerid] = 0;
pBankRobbing[playerid] = 0;
return 1;
}
else
{
new string[128];//We are defining a new string for the formatted message that we are displaying later on.
new cash = random(2000000);
GivePlayerCash(playerid, cash);
/*
With the fuction above 'new cash = random(200000);
GivePlayerMoney(playerid, cash);' we give the player
a random amount of money from $0 - $200,000
*/
//Here below we use the string we defined above to format the message itself and display it to the player.
format(string, sizeof(string), "You have successfully robbed $%d from the bank!", cash);
SendClientMessage(playerid, COLOR_GREEN, string);
format(string, sizeof(string), "[BREAKING NEWS] The suspect %s has successfully rob the money bank", GetPlayerNameEx(playerid));
SendClientMessageToAll(COLOR_REALRED, string);
++PlayerInfo[playerid][pCrimes];
++PlayerInfo[playerid][pCrimes];
++PlayerInfo[playerid][pCrimes];
SetPlayerWantedLevel(playerid, ++PlayerInfo[playerid][pWantedLevel]);
SetPlayerWantedLevel(playerid, ++PlayerInfo[playerid][pWantedLevel]);
SetPlayerWantedLevel(playerid, ++PlayerInfo[playerid][pWantedLevel]);
++PlayerInfo[playerid][pCrimes];
++PlayerInfo[playerid][pCrimes];
++PlayerInfo[playerid][pCrimes];
SetPlayerWantedLevel(playerid, ++PlayerInfo[playerid][pWantedLevel]);
SetPlayerWantedLevel(playerid, ++PlayerInfo[playerid][pWantedLevel]);
SetPlayerWantedLevel(playerid, ++PlayerInfo[playerid][pWantedLevel]);
}
return 1;
}

GetName(playerid)
{
new fdqkljqfdhqlsdhjf[MAX_PLAYER_NAME+1]; // I used a random name to be sure it won't get created twice in the script
GetPlayerName(playerid, fdqkljqfdhqlsdhjf, sizeof(fdqkljqfdhqlsdhjf));
return fdqkljqfdhqlsdhjf;
}
|
Use this function instead of your GivePlayerNameEx
PHP код:
EDIT : Show the timer which calls the function also please. |

stock GetPlayerNameEx(playerid)
{
new
sz_playerName[MAX_PLAYER_NAME],
i_pos;
GetPlayerName(playerid, sz_playerName, MAX_PLAYER_NAME);
while ((i_pos = strfind(sz_playerName, "_", false, i_pos)) != -1) sz_playerName[i_pos] = ' ';
return sz_playerName;
}
CMD:robbank(playerid, params[])
{
if(robpossible == 1) //If the bank can be robbed we continue below
{
if(IsPlayerInRangeOfPoint(playerid, 2.0, 2319.2310,-2.0349,26.7496))
{//Next thing we do is, we check if we are at the bank interior ^^
if(AdminDuty[playerid] == 1) return SendClientMessage(playerid, COLOR_GRAD1, "You cant rob bank while on duty ^^");
if(PlayerInfo[playerid][pCrimes] == 3 && PlayerInfo[playerid][pWantedLevel] == 3) return SendClientMessage(playerid, COLOR_GRAD1, "You cannot /robbank when you have 3+ star! Be cool!");
robpossible = 0; //Then we set the bank so it cannot be robbed
SetTimer("waittimer", 900000, false); //Normal Mode 5 minutes
//SetTimer("waittimer", 65000, false); //Test Mode 65 seconds
/* We also run another timer(1 minute) for the function that is
actually going to give us the money and a user friendly message.
*/
/*
Add a function that would notify the police.
*/
SendClientMessageToAll(COLOR_GREEN,"[BREAKING NEWS] Bank is being robbed, do not come near the bank!");
SendClientMessageToAll(0x0080FFFF, "Alerting all POLICE to come at bank As Soon as possible!!!");
SendClientMessageToAll(0x0080FFFF, "Lahat ng police PUMUNTA sa BANK ngayon din!!!");
SendClientMessage(playerid, 0xFF0000FF, "You are robbing the bank, the police has been notified!");
SendClientMessage(playerid, 0x008000FF, "You gotta stay 5 minutes before you get the moneys!!!");
++PlayerInfo[playerid][pCrimes];
++PlayerInfo[playerid][pCrimes];
++PlayerInfo[playerid][pCrimes];
SetPlayerWantedLevel(playerid, ++PlayerInfo[playerid][pWantedLevel]);
SetPlayerWantedLevel(playerid, ++PlayerInfo[playerid][pWantedLevel]);
SetPlayerWantedLevel(playerid, ++PlayerInfo[playerid][pWantedLevel]);
GameTextForPlayer(playerid, "~r~ALERT: BANK IS BEING ROB!", 3, 5000);
SetTimer("robtimer", 300000, false);
RobberBusted[playerid] = 0;
pBankRobbing[playerid] = 1;
} else return SendClientMessage(playerid, COLOR_WHITE, "You are not in BANK SAFE!!");
} else {
SendClientMessage(playerid, COLOR_WHITE, "You can't rob the bank right now! Already rob or waiting for cool down");
}
return 1;
}
SetTimerEx("robtimer", 300000, false, "i", playerid);
|
The problem comes from "SetTimer".
If a function hasn't any parameter (so anything between the () ), you use SetTimer. But the function robtimer has a parameter or more than one, you must use SetTimerEx. There are two additionnal parameters in SetTimerEx : the parameter format (you must put it between quotes, just like sscanf) and the parameters theirselves. In your case, it should be PHP код:
Using strings and array isn't possible yet with SetTimer, but if you use y_timers, it becomes possible. |
|
Greetings!
Thanks for your reply! Can you please explain why there "i" at SetTimerEx? What should i put there? Thanks! |
|
Special format indicating the types of values the timer will pass. "i" stands for the integer, which is a decimal number (you can also use "d" instead of the "i". It will cause the same result). "i" operator will provide a timer the player's ID to the function that is supposed to be called.
edit:// Too late. |
OnPlayerDisconnect
if(pBankRobbing[giveplayerid] == 1)
{
RobberBusted[giveplayerid] = 1;
SetTimerEx("robtimer", 0 , false, "i", playerid);
pBankRobbing[giveplayerid] = 0;
}
public robtimer
RobberBusted[playerid] == 1
public robtimer(playerid)
{
if(RobberBusted[playerid] == 1)
{
SendClientMessageToAll(COLOR_GREEN, "[BREAKING NEWS]: Bank Robberry Failed! Suspect has been BUSTED!");
SendClientMessage(playerid, COLOR_YELLOW, "You were busted by the POLICE, Bank Robbery Fail!");
RobberBusted[playerid] = 0;
pBankRobbing[playerid] = 0;
return 1;
}
else if(RobberBusted[playerid] == 2)
{
SendClientMessageToAll(COLOR_RED, "[BREAKING NEWS]: Bank Robberry failed! Suspect has been eliminated ((Leaving/Timeout at server))");
RobberBusted[playerid] = 0;
pBankRobbing[playerid] = 0;
return 1;
}
else
{
new string[128];//We are defining a new string for the formatted message that we are displaying later on.
new cash = random(2000000);
GivePlayerCash(playerid, cash);
/*
With the fuction above 'new cash = random(200000);
GivePlayerMoney(playerid, cash);' we give the player
a random amount of money from $0 - $200,000
*/
//Here below we use the string we defined above to format the message itself and display it to the player.
format(string, sizeof(string), "You have successfully robbed $%d from the bank!", cash);
SendClientMessage(playerid, COLOR_GREEN, string);
format(string, sizeof(string), "[BREAKING NEWS] The suspect %s has successfully rob the money bank", GetPlayerNameEx(playerid));
SendClientMessageToAll(COLOR_REALRED, string);
++PlayerInfo[playerid][pCrimes];
++PlayerInfo[playerid][pCrimes];
++PlayerInfo[playerid][pCrimes];
SetPlayerWantedLevel(playerid, ++PlayerInfo[playerid][pWantedLevel]);
SetPlayerWantedLevel(playerid, ++PlayerInfo[playerid][pWantedLevel]);
SetPlayerWantedLevel(playerid, ++PlayerInfo[playerid][pWantedLevel]);
++PlayerInfo[playerid][pCrimes];
++PlayerInfo[playerid][pCrimes];
++PlayerInfo[playerid][pCrimes];
SetPlayerWantedLevel(playerid, ++PlayerInfo[playerid][pWantedLevel]);
SetPlayerWantedLevel(playerid, ++PlayerInfo[playerid][pWantedLevel]);
SetPlayerWantedLevel(playerid, ++PlayerInfo[playerid][pWantedLevel]);
}
return 1;
}