26.06.2013, 05:17
Hello, how can I kill my timer for robbing the bank when a player is being shot at and has less than 20hp, KillTimer(robtimer); gives me an error
Here is my full code
The errors and warning is under OnPlayerUpdate. I commented the lines
Any help would be greatly appreciated! Thank you!
pawn Код:
C:\Users\Josh\Desktop\DEVIL NPC BUS\filterscripts\robb.pwn(115) : warning 202: number of arguments does not match definition
C:\Users\Josh\Desktop\DEVIL NPC BUS\filterscripts\robb.pwn(117) : error 076: syntax error in the expression, or invalid function call
pawn Код:
/*
This script/application is created by UnlimitedDeveloper from SAMP forums
and it's supposed to be shared only at SAMP forums, nowhere else!
If any copy of this script is found on another forum, it will be taken down.
*/
#include <a_samp>
#include <zcmd>
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_PURPLE 0xC2A2DAAA
#define DIALOGITEMS 1
#define DIALOGITEMS2 2
//Function forwarding
/*
Firstly we have to forward the functions that we are going
to use later in our sript.
*/
forward robtimer(playerid);
forward waittimer();
//Variables
/*
We are adding a NEW Variable so we can determine wether the bank
can or cannot be robber at a certain time.
*/
new robpossible;
public OnFilterScriptInit()
{
/*
When the filterscript executes itself it's setting the 'robpossible'
variable to 1 which means that we can rob the bank right after we login.
*/
robpossible = 1;
return 1;
}
//Command(s)
CMD:robbank(playerid, params[])
{
if(robpossible == 1) //If the bank can be robbed we continue below
{
if(IsPlayerInRangeOfPoint(playerid, 3, 2144.2012,1640.6323,993.5761))
{
robpossible = 0;
//SetTimer("waittimer", 5000, false); //for testing
//SetTimer("robtimer", 5000, false); //Test Mode 6 seconds
SetTimer("waittimer", 5500000, false);
SetTimer("robtimer", 300000, false);
SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid)+4);
TogglePlayerControllable(playerid, 0);
SendClientMessage(playerid, COLOR_WHITE, "You are now robbing the bank, the police have been notified!");
SendClientMessage(playerid, COLOR_WHITE, "You must stay in the bank for 5 minutes in order to rob it!");
SendClientMessageToAll(COLOR_PURPLE, "*** . . : : You may hear alarms and sirens screaming outside the bank in Mulholland: : . . ***");
new string[18];
format(string, sizeof(string), "Robbing the bank");
GameTextForPlayer(playerid, string, 299995, 5);
//GameTextForPlayer(playerid, string, 6000, 5); //for testing
}
} else {
SendClientMessage(playerid, COLOR_WHITE, "You can't rob the bank right now!");
}
return 1;
}
CMD:buyitems(playerid, params[])
{
if(IsPlayerInRangeOfPoint(playerid, 7, 2561.2803,1403.9896,7699.5845))
ShowPlayerDialog(playerid, DIALOGITEMS, DIALOG_STYLE_LIST, "Items menu - New items soon!","Bank robbery timer reset (150k)","Buy","Cancel");
}
//Test CMDS
/*CMD:bank(playerid, params[])
{
SetPlayerPos(playerid, 2144.2012,1640.6323,993.5761);
SetPlayerInterior(playerid, 1);
}
CMD:vip(playerid, params[])
{
SetPlayerPos(playerid, 2561.2803,1403.9896,7699.5845);
GivePlayerMoney(playerid, 200000);
TogglePlayerControllable(playerid, 0);
}
CMD:unfreeze(playerid, params[])
{
TogglePlayerControllable(playerid, 1);
}
CMD:setmoney(playerid, params[])
{
GivePlayerMoney(playerid, 0);
return 1;
}*/
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
if(IsPlayerInRangeOfPoint(playerid, 3, 2144.2012,1640.6323,993.5761))
{
if(issuerid !=INVALID_PLAYER_ID && weaponid == 20 || 21 || 22 || 23 || 24 || 25 || 26 || 27 || 28 || 29 || 30 || 31 || 32 || 33 || 34)
{
robpossible = 1;
}
}
return 1;
}
public OnPlayerUpdate(playerid)
{
if(IsPlayerInRangeOfPoint(playerid, 3, 2144.2012,1640.6323,993.5761))
{
if(GetPlayerHealth(playerid) <20) return SendClientMessage(playerid, COLOR_WHITE, "You have less than 20hp, bank robbery cancelled!"); //I am receiving the warning on this line
TogglePlayerControllable(playerid, 1);
KillTimer(robtimer); //This line returns an error, I need it to cancel the robtimer so if the player is shot at and has less than 20hp he doesn't receive the money
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOGITEMS)
{
if(response)
{
switch(listitem)
{
case 0:
{
ShowPlayerDialog(playerid, DIALOGITEMS2, DIALOG_STYLE_MSGBOX, "Are you sure you want to buy this item?","Buying this item will reset the bank timer so you're\nable to rob the bank again without waiting 30 minutes.\nRemember: There is no point in buying this timer if the bank has\nnot been robbed in the past 30 minutes.","Buy item","Cancel");
}
}
}
}
if(dialogid == DIALOGITEMS2)
{
if(response)
{
if(GetPlayerMoney(playerid) <150000) return SendClientMessage(playerid, COLOR_WHITE, "You do not have enough money to purchase this item!");
SendClientMessage(playerid, COLOR_WHITE, "You have purchased a bank robbery timer reset!");
SendClientMessage(playerid, COLOR_WHITE, "The bank timer has been reset!");
GivePlayerMoney(playerid, -150000);
robpossible = 1;
}
}
return 1;
}
//Functions
public robtimer(playerid)
{
new string2[128];
new cash = random(200000);
GivePlayerMoney(playerid, cash);
TogglePlayerControllable(playerid, 1);
format(string2, sizeof(string2), "You have successfully robbed $%d from the bank!", cash);
SendClientMessage(playerid, COLOR_WHITE, string2);
new string3[18];
format(string3, sizeof(string3), "Sucessful!");
GameTextForPlayer(playerid, string3, 2000, 5);
}
public waittimer()
{
robpossible = 1;
}
Any help would be greatly appreciated! Thank you!