Need help with modifying a command! -
StrikerZ - 06.10.2016
Hey there. I made a /robstore command.
Код:
CMD:robstore(playerid, params[])
{
if(!Store1(playerid) || !Store2(playerid) || !Store3(playerid))
{
SCM(playerid, COLOR_RED, "[ERROR]: You need to be in a store to perform this action!");
}
if(gTeam[playerid] == LSPD)
{
SCM(playerid, COLOR_RED, "[ERROR]: COPS can't perform this action!");
}
SendClientMessage(playerid, COLOR_YELLOW, "[INFORMATION]: Robbery has been started, please wait 45 seconds! Note: You can't perfrom another rob within 20 seconds.");
SetTimerEx("Robbing2", 45000, false, "i", playerid);
wantedlevel = GetPlayerWantedLevel(playerid);
SetPlayerWantedLevel(playerid, 1);
Robbing[playerid] = 1;
if(RobCooldown[playerid] > 0) return 0;
if(Robbing[playerid] > 0) return 0;
return 1;
}
It works successfully but the problem is that when player types /robstore command the info text is sent + the
Код:
if(RobCooldown[playerid] > 0) return 0;
if(Robbing[playerid] > 0) return 0;
is executed at the same time which gives server:unknown command on the screen. So can i somehow make this
Код:
if(RobCooldown[playerid] > 0) return 0;
if(Robbing[playerid] > 0) return 0;
execute at that time when player again types that command.
Re: Need help with modifying a command! -
Dayrion - 06.10.2016
Change return 0, by return 1;
Re: Need help with modifying a command! -
StrikerZ - 06.10.2016
But wait return 1; will execute the command again
Re: Need help with modifying a command! -
Dayrion - 06.10.2016
No'p. If you return something the command will stop. If you will you return 0, OnPlayerCommandPerformed(playerid, cmdtext[], success) will be called, that's why you have 2 messages (default message is Server: Unknow command).
Re: Need help with modifying a command! -
StrikerZ - 06.10.2016
And yeah is it possible like a player exits that store then the timer of rob will stop? + how can i show the countdown of the timer on screen?
Re: Need help with modifying a command! -
SickAttack - 06.10.2016
Returning a value will exit the function (commands are functions in regards to zcmd).
------------
Use a TextDraw or GameText or various messages to show the time left.
Use KillTimer to stop a timer set to repeat or that hasn't ran yet.
Re: Need help with modifying a command! -
StrikerZ - 06.10.2016
And yeah is it possible like a player exits that store then the timer of rob will stop?
Re: Need help with modifying a command! -
StrikerZ - 06.10.2016
oke so i made the cmd like this but it isn't getting the time of the timer...
Код:
CMD:robstore(playerid, params[])
{
if(!Store1(playerid) || !Store2(playerid) || !Store3(playerid))
{
SCM(playerid, COLOR_RED, "[ERROR]: You need to be in a store to perform this action!");
}
if(gTeam[playerid] == LSPD)
{
SCM(playerid, COLOR_RED, "[ERROR]: COPS can't perform this action!");
}
SetTimerEx("Robbing2", 45000, false, "i", playerid);
wantedlevel = GetPlayerWantedLevel(playerid);
SetPlayerWantedLevel(playerid, 1);
Robbing[playerid] = 1;
RobbingTimeLeft[playerid] = GetTickCount();
if(RobCooldown[playerid] > 0)
{
new string[120];
format(string, sizeof(string), "You need to wait %d before robbing again.",(GetTickCount()-RobCooldownTimeLeft[playerid])/1000);
SCM(playerid, -1, string);
return 1;
}
if(Robbing2[playerid] > 0)
{
new string[120];
format(string, sizeof(string), "Robbing Time: Left %d.",(GetTickCount()-RobbingTimeLeft[playerid])/1000);
SCM(playerid, -1, string);
SendClientMessage(playerid, COLOR_YELLOW, "[INFORMATION]: Robbery has been started, please wait 45 seconds! Use /robstore again to the see the time remaining.");
return 1;
}
return 1;
}
It shows 0 seconds on the screen