aDuty Help -
silverms - 09.03.2017
hey so I have this command that should when player type the command to be view on the map all the players can see him but it isn't workin good here is the script
PHP код:
CMD:aduty(playerid, params[])
{
if(adlvl[playerid]<1) return 0;
new pname[64], str[150];
GetPlayerName(playerid, pname, sizeof(pname));
for(new i=0; i< MAX_PLAYERS; i++)
{
if(aDuty[playerid]==0)
{
SetPlayerMarkerForPlayer(playerid, i, (GetPlayerColor(playerid)));
format(str,sizeof(str),"Admin[%s] Is Now [ON] Duty", pname);
SendClientMessageToAll(COLOR_GREEN,str);
aDuty[playerid]=1;
return 1;
}
if(aDuty[playerid]==1)
{
SetPlayerMarkerForPlayer(playerid, i, 00);
format(str,sizeof(str),"Admin[%s] Is Now [OFF] Duty", pname);
SendClientMessageToAll(COLOR_GREEN,str);
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 100);
aDuty[playerid]=0;
return 1;
}
return 1;
}
return 1;
}
Re: aDuty Help -
Immortal99 - 10.03.2017
Firstly on top of ur script add:
new aDuty[MAX_PLAYERS];
Secondly Under OnPlayerConnect add:
aDuty[playerid] = 0; // This will set the players admin duty off when he connects
Do the same under OnPlayerDisconect
And then here is the code fixed:
PHP код:
.CMD:aduty(playerid, params[])
{
if(adlvl[playerid]<1) return 0;
new pname[64], str[150];
GetPlayerName(playerid, pname, sizeof(pname));
for(new i=0; i< MAX_PLAYERS; i++)
{
if(aDuty[playerid] == 0)
{
SetPlayerMarkerForPlayer(playerid, i, (GetPlayerColor(playerid)));
format(str,sizeof(str),"Admin[%s] Is Now [ON] Duty", pname);
SendClientMessageToAll(COLOR_GREEN,str);
aDuty[playerid] = 1;
// You don't return 1 else it wouldn't set him on duty
}
else if (aDuty[playerid] == 1) // This Will check if he's on duty
{
SetPlayerMarkerForPlayer(playerid, i, 00);
format(str,sizeof(str),"Admin[%s] Is Now [OFF] Duty", pname);
SendClientMessageToAll(COLOR_GREEN,str);
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 100);
aDuty[playerid] = 0;
// Again u don't return 1
}
return 1;
}
return 1;
}
I did this on my mobile so I didn't test it, but I think it should work
Re: aDuty Help -
Toroi - 10.03.2017
Let me point out that you don't really want to use the SendClientMessageToAll function inside a player loop, or any other function beside SetPlayerMarkerForPlayer.
Also, remove the loop's return, as it will break the loop and its purpose.
You've to restructure it a lot for it to work efficiently.
Re: aDuty Help -
silverms - 10.03.2017
Every thing is working fine he is go8ng on duty but ue isnt vuewing on the map like showplayermarkers
Re: aDuty Help -
Toroi - 10.03.2017
It is not 'working fine' if it does not work.
The only thing you need the loop for is the
SetPlayerMarkerForPlayer function. Instead, you're putting every function inside the loop, which will cause a massive function flood.
However, is not it easier to use the
SetPlayerColor function? It does the same and it's for everyone, so you save a loop.