27.02.2018, 11:24
is loops working under onplayerdisconnected callback ? , because its seems to be not working right there.
public OnPlayerDisconnect(playerid, reason) // loops didn't work while they do same functions
{
for(new i=0; i < MAX_PLAYERS; i++)
{
if (TaxiDuty[playerid] == 1)
{
TaxiDuty[playerid] = 0;
Drivers -= 1;
}
if(TaxiDuty[i] == 1)
{
SendClientMessage(i, COLOR, "Has left the game");
}
}
return 1;
}
public OnPlayerDeath(playerid, killerid, reason) // worked well
{
for(new i=0; i < MAX_PLAYERS; i++)
{
if (TaxiDuty[playerid] == 1)
{
TaxiDuty[playerid] = 0;
Drivers -= 1;
}
if(TaxiDuty[i] == 1)
{
SendClientMessage(i, COLOR, "Has left the game");
}
}
return 1;
}
|
I don't understand why you need a code. anyways here is it
Код:
public OnPlayerDisconnect(playerid, reason)
{
for(new i=0; i < MAX_PLAYERS; i++)
{
if (TaxiDuty[playerid] == 1)
{
TaxiDuty[playerid] = 0;
Drivers -= 1;
}
if(TaxiDuty[i] == 1)
{
SendClientMessage(i, COLOR, "Has left the game");
}
}
return 1;
}
public OnPlayerDeath(playerid, killerid, hittype) // worked well
{
for(new i=0; i < MAX_PLAYERS; i++)
{
if (TaxiDuty[playerid] == 1)
{
TaxiDuty[playerid] = 0;
Drivers -= 1;
}
if(TaxiDuty[i] == 1)
{
SendClientMessage(i, COLOR, "Has left the game");
}
}
return 1;
}
|
public OnPlayerDisconnect(playerid, reason)
{
new string[150];
if (TaxiDuty[playerid] == 1)
{
new name[35];
TaxiDuty[playerid] = 0;
Drivers -= 1;
for(new i=0; i < MAX_PLAYERS; i++)
{
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s has left the game", name);
SendClientMessage(i, -1, string);
}
}
return 1;
}
for(new i=0; i < MAX_PLAYERS; i++)
{
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s has left the game", name);
SendClientMessage(i, -1, string);
}
GetPlayerName(playerid, name, sizeof(name)); format(string, sizeof(string), "%s has left the game", name); SendClientMessageToAll(-1, string);
|
Guys , i don't need to fix the code. its just an example.
my problem is the whole code is not responding if it putted under onplayerdisconnect also under a loop. thats all same code with same functions on player death coping and pasting them at onplayerdisconnect, but it doesn't responde at all |