help dynamic rob point -
drichie - 04.07.2013
im just trying to make dynamic rob point so the admin can make rob points whenever or where he wants to....im just experimenting here coz i think its possible..unfortunately im not good when it comes to loopings
help me whenever i type /rob to the rob point i make it loops on how many max rob point define
#define MAX_PICK 50
for example im not in a rob point or i failed in robbing the client messages will be seen 50 times in the chat box
here is my /rob command
pawn Код:
CMD:rob(playerid,params[])
{
for(new i=0; i<MAX_PICK; i++)
{
if(IsPlayerInRangeOfPoint(playerid,2,PickInfo[i][pX], PickInfo[i][pY], PickInfo[i][pZ]) && GetPlayerVirtualWorld(playerid) == PickInfo[i][pVw] && GetPlayerInterior(playerid) == PickInfo[i][pInt])
{
ApplyAnimation(playerid, "ROB_BANK", "CAT_SAFE_ROB", 4.0, 1, 0, 0,0, 1);
robtime = SetTimer("robtimer",1000,true);
}
else
{
SCM(playerid,-1,"You are not in a rob point");
}
}
return 1;
}
forward robtimer(playerid);
public robtimer(playerid)
{
for(new i=0; i<MAX_PICK; i++)
{
CountDownVar--;
new str[128];
format(str, sizeof(str), "Count Down: %d",CountDownVar);
GameTextForPlayer(playerid,str,1000,6);
if(CountDownVar == 0)
{
new rand = random(999);
GiveDrichMoney(playerid,rand);
format(str,128," %s has robbed %i",GetName(playerid),rand);
SCM(playerid,-1,str);
ClearAnimations(playerid);
KillTimer(robtime);
CountDownVar = 15;
}
else if(!IsPlayerInRangeOfPoint(playerid,1.0,PickInfo[i][pX], PickInfo[i][pY], PickInfo[i][pZ]) || GetPlayerVirtualWorld(playerid) != PickInfo[i][pVw] || GetPlayerInterior(playerid) != PickInfo[i][pInt])
{
KillTimer(robtime);
CountDownVar = 15;
SCM(playerid,-1, "[ROBBERY]: Robbery has failed");
}
}
return 1;
}
this one i used to create auto generated id rob point
pawn Код:
CMD:crob(playerid, params[])
{
new string[128];
for(new i=0; i<MAX_PICK; i++)
{
if(!PickInfo[i][pPick])
{
GetPlayerPos(playerid, PickInfo[i][pX], PickInfo[i][pY], PickInfo[i][pZ]);
PickInfo[i][pInt] = GetPlayerInterior(playerid);
PickInfo[i][pVw] = GetPlayerVirtualWorld(playerid);
PickInfo[i][pPick] = CreateDynamicPickup(1210, 1, PickInfo[i][pX], PickInfo[i][pY], PickInfo[i][pZ]+0.2,PickInfo[i][pVw],PickInfo[i][pInt]);
format(string, sizeof(string), "ID: %d", i);
PickInfo[i][pText] = CreateDynamic3DTextLabel(string,-1,PickInfo[i][pX], PickInfo[i][pY], PickInfo[i][pZ]+0.3, 15);
format(string, sizeof(string), " You have set a robpoint ID %d to your coordinates. (Int: %d | VW: %d)", i, GetPlayerInterior(playerid), GetPlayerVirtualWorld(playerid));
SCM(playerid,COLOR_LIGHTBLUE, string);
i = MAX_PICK;
}
}
return 1;
}
Re: help dynamic rob point -
Goldilox - 04.07.2013
For the point part, try returning the SCM, which I've done it. For the failed part, I don't know, it looks alright to me.
EDIT: I've made an array that makes the RobFail to 1 when player failed and sends the client message out of the loops, that might help prevent the repeat. I am not sure, just check this thing and report if have any issues.
pawn Код:
// On top
new RobFail[MAX_PLAYERS];
//On Player Connect
RobFail[playerid] = 0;
CMD:rob(playerid,params[])
{
for(new i=0; i<MAX_PICK; i++)
{
if(IsPlayerInRangeOfPoint(playerid,2,PickInfo[i][pX], PickInfo[i][pY], PickInfo[i][pZ]) && GetPlayerVirtualWorld(playerid) == PickInfo[i][pVw] && GetPlayerInterior(playerid) == PickInfo[i][pInt])
{
ApplyAnimation(playerid, "ROB_BANK", "CAT_SAFE_ROB", 4.0, 1, 0, 0,0, 1);
robtime = SetTimer("robtimer",1000,true);
}
else return SCM(playerid,-1,"You are not in a rob point");
}
return 1;
}
forward robtimer(playerid);
public robtimer(playerid)
{
for(new i=0; i<MAX_PICK; i++)
{
CountDownVar--;
new str[128];
format(str, sizeof(str), "Count Down: %d",CountDownVar);
GameTextForPlayer(playerid,str,1000,6);
if(CountDownVar == 0)
{
new rand = random(999);
GiveDrichMoney(playerid,rand);
format(str,128," %s has robbed %i",GetName(playerid),rand);
SCM(playerid,-1,str);
ClearAnimations(playerid);
KillTimer(robtime);
CountDownVar = 15;
}
else if(!IsPlayerInRangeOfPoint(playerid,1.0,PickInfo[i][pX], PickInfo[i][pY], PickInfo[i][pZ]) || GetPlayerVirtualWorld(playerid) != PickInfo[i][pVw] || GetPlayerInterior(playerid) != PickInfo[i][pInt])
{
KillTimer(robtime);
CountDownVar = 15;
RobFail[playerid] = 1;
}
if(RobFail[playerid] == 1) return SCM(playerid,-1, "[ROBBERY]: Robbery has failed");
}
return 1;
}
Re: help dynamic rob point -
GeniusPobs - 04.07.2013
I see ur RobFail, and it's useless...
I've edited it a little bit. Didn't test but it should work.
pawn Код:
CMD:rob(playerid,params[])
{
for(new i=0; i<MAX_PICK; i++)
{
if(IsPlayerInRangeOfPoint(playerid,2,PickInfo[i][pX], PickInfo[i][pY], PickInfo[i][pZ]) && GetPlayerVirtualWorld(playerid) == PickInfo[i][pVw] && GetPlayerInterior(playerid) == PickInfo[i][pInt])
{
ApplyAnimation(playerid, "ROB_BANK", "CAT_SAFE_ROB", 4.0, 1, 0, 0,0, 1);
robtime = SetTimer("robtimer",1000,true);
}
else
{
return SCM(playerid,-1,"You are not in a rob point");
}
}
return 1;
}
forward robtimer(playerid);
public robtimer(playerid)
{
for(new i=0; i<MAX_PICK; i++)
{
CountDownVar--;
new str[128];
format(str, sizeof(str), "Count Down: %d",CountDownVar);
GameTextForPlayer(playerid,str,1000,6);
if(CountDownVar == 0)
{
if(!IsPlayerInRangeOfPoint(playerid,1.0,PickInfo[i][pX], PickInfo[i][pY], PickInfo[i][pZ]) || GetPlayerVirtualWorld(playerid) != PickInfo[i][pVw] || GetPlayerInterior(playerid) != PickInfo[i][pInt])
{
KillTimer(robtime);
ClearAnimations(playerid);
CountDownVar = 15;
return SCM(playerid,-1, "[ROBBERY]: Robbery has failed");
}
new rand = random(999);
GiveDrichMoney(playerid,rand);
format(str,128," %s has robbed %i",GetName(playerid),rand);
SCM(playerid,-1,str);
ClearAnimations(playerid);
KillTimer(robtime);
CountDownVar = 15;
}
}
return 1;
}
And btw, nice userbars :>
Re: help dynamic rob point -
drichie - 04.07.2013
tnx for the help but after using that it always says im not in a rob point..and the only point where the timer will cal is only in the first created rob point only
btw i think the userbar i used comes from your signature hehe
Re: help dynamic rob point -
Vince - 04.07.2013
NEVER return inside a loop body unless you explicitly want to break the loop.
Re: help dynamic rob point -
drichie - 04.07.2013
so GeniusPobs was right with his code