PDA

View Full Version : Help


Xdrime
08/05/2016, 06:31 PM
Guys im using this code, the problem is when i use it in game it doesnt work :( can someone fix it for me ?
CMD:healall(playerid, params[])
{
new str[128];
if(pInfo[playerid][Logged] == 0) return SendClientMessage(playerid, COLOR_RED, "[Error]: You must be logged in!");
if(pInfo[playerid][Admin] >= 4)
{
SendAdminCMD(playerid, "healall", 0);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && (i != playerid) && (pInfo[playerid][Admin] > pInfo[i][Admin]) && InP[i] == 0 && InDM[i] == 0 && pInfo[i][Jail] == 0 && God[i][0] == 0 && God[i][1] == 0)
{
PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
SetPlayerHealth(i, 100.0);
SetPlayerArmour(playerid, 100.0);
}
}
PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
format(str, sizeof(str), "Administrator %s(%d) has healed all players!", GetName(playerid), playerid);
SendClientMessageToAll(COLOR_YELLOW, str);
}
else return SendClientMessage(playerid, COLOR_RED, EACMD);
return 1;
}
even this one
CMD:armourall(playerid, params[])
{
new str[128];
if(pInfo[playerid][Logged] == 0) return SendClientMessage(playerid, COLOR_RED, "[Error]: You must be logged in!");
if(pInfo[playerid][Admin] >= 4)
{
SendAdminCMD(playerid, "armourall", 0);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && (i != playerid) && (pInfo[playerid][Admin] > pInfo[i][Admin]) && InDM[i] == 0)
{
PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
SetPlayerArmour(i, 100.0);
}
}
PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
format(str, sizeof(str), "Administrator %s(%d) has armoured all players!", GetName(playerid), playerid);
SendClientMessageToAll(COLOR_YELLOW, str);
}
else return SendClientMessage(playerid, COLOR_RED, EACMD);
return 1;
}

Dayrion
08/05/2016, 06:59 PM
When you type the command, nothing appears ?
Put some print, every like that :
CMD:healall(playerid, params[])
{
new str[128];
if(pInfo[playerid][Logged] == 0) return SendClientMessage(playerid, COLOR_RED, "[Error]: You must be logged in!");
print("Starting.. /healall");
if(pInfo[playerid][Admin] >= 4)
{
SendAdminCMD(playerid, "healall", 0);
printf("Player (ID: %i) Allowed to heal all players.", playerid);
for(new i = 0; i < MAX_PLAYERS; i++)
{
printf("Player : ID : %i - Heal ?", i);
if(IsPlayerConnected(i) && (i != playerid) && (pInfo[playerid][Admin] > pInfo[i][Admin]) && InP[i] == 0 && InDM[i] == 0 && pInfo[i][Jail] == 0 && God[i][0] == 0 && God[i][1] == 0)
{
PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
SetPlayerHealth(i, 100.0);
SetPlayerArmour(playerid, 100.0);
printf("Player : ID : %i - Healed !", i);
}
}
print("All Player get healed.");
PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
format(str, sizeof(str), "Administrator %s(%d) has healed all players!", GetName(playerid), playerid);
SendClientMessageToAll(COLOR_YELLOW, str);
}
else return SendClientMessage(playerid, COLOR_RED, EACMD);
return 1;
}
And show us what the command invit return

Xdrime
08/05/2016, 07:04 PM
When you type the command, nothing appears ?
Put some print, every like that :
CMD:healall(playerid, params[])
{
new str[128];
if(pInfo[playerid][Logged] == 0) return SendClientMessage(playerid, COLOR_RED, "[Error]: You must be logged in!");
print("Starting.. /healall");
if(pInfo[playerid][Admin] >= 4)
{
SendAdminCMD(playerid, "healall", 0);
printf("Player (ID: %i) Allowed to heal all players.", playerid);
for(new i = 0; i < MAX_PLAYERS; i++)
{
printf("Player : ID : %i - Heal ?", i);
if(IsPlayerConnected(i) && (i != playerid) && (pInfo[playerid][Admin] > pInfo[i][Admin]) && InP[i] == 0 && InDM[i] == 0 && pInfo[i][Jail] == 0 && God[i][0] == 0 && God[i][1] == 0)
{
PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
SetPlayerHealth(i, 100.0);
SetPlayerArmour(playerid, 100.0);
printf("Player : ID : %i - Healed !", i);
}
}
print("All Player get healed.");
PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
format(str, sizeof(str), "Administrator %s(%d) has healed all players!", GetName(playerid), playerid);
SendClientMessageToAll(COLOR_YELLOW, str);
}
else return SendClientMessage(playerid, COLOR_RED, EACMD);
return 1;
}
And show us what the command invit return

The thing is it appears but it doesnt heal the players

Slawiii
08/05/2016, 07:10 PM
This command can't heal you and can't heal an admin have a higher level than you and more
If u test it with yourself will not work

Xdrime
08/05/2016, 07:14 PM
This command can't heal you and can't heal an admin have a higher level than you and more
If u test it with yourself will not work
true :o
can you please tell me how i can make it for everyone ?

Slawiii
08/05/2016, 07:21 PM
Try this

CMD:healall(playerid, params[])
{
new str[128];
if(pInfo[playerid][Logged] == 0) return SendClientMessage(playerid, COLOR_RED, "[Error]: You must be logged in!");
if(pInfo[playerid][Admin] >= 4)
{
SendAdminCMD(playerid, "healall", 0);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && InP[i] == 0 && InDM[i] == 0 && pInfo[i][Jail] == 0 && God[i][0] == 0 && God[i][1] == 0)
//if(IsPlayerConnected(i)) // this mean to everyone is connected ingame.
{
PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
SetPlayerHealth(i, 100.0);
SetPlayerArmour(playerid, 100.0);
}
}
PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
format(str, sizeof(str), "Administrator %s(%d) has healed all players!", GetName(playerid), playerid);
SendClientMessageToAll(COLOR_YELLOW, str);
}
else return SendClientMessage(playerid, COLOR_RED, EACMD);
return 1;
}

Xdrime
08/05/2016, 07:58 PM
Thank you man it worked finaly <3
i'd apperciate it if you fix this for me also
CMD:armourall(playerid, params[])
{
new str[128];
if(pInfo[playerid][Logged] == 0) return SendClientMessage(playerid, COLOR_RED, "[Error]: You must be logged in!");
if(pInfo[playerid][Admin] >= 4)
{
SendAdminCMD(playerid, "armourall", 0);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && (i != playerid) && (pInfo[playerid][Admin] > pInfo[i][Admin]) && InDM[i] == 0)
{
PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
SetPlayerArmour(i, 100.0);
}
}
PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
format(str, sizeof(str), "Administrator %s(%d) has armoured all players!", GetName(playerid), playerid);
SendClientMessageToAll(COLOR_YELLOW, str);
}
else return SendClientMessage(playerid, COLOR_RED, EACMD);
return 1;
}

Slawiii
08/05/2016, 08:00 PM
CMD:armourall(playerid, params[])
{
new str[128];
if(pInfo[playerid][Logged] == 0) return SendClientMessage(playerid, COLOR_RED, "[Error]: You must be logged in!");
if(pInfo[playerid][Admin] >= 4)
{
SendAdminCMD(playerid, "armourall", 0);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && InDM[i] == 0)
{
PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
SetPlayerArmour(i, 100.0);
}
}
PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
format(str, sizeof(str), "Administrator %s(%d) has armoured all players!", GetName(playerid), playerid);
SendClientMessageToAll(COLOR_YELLOW, str);
}
else return SendClientMessage(playerid, COLOR_RED, EACMD);
return 1;
}

Xdrime
08/05/2016, 08:27 PM
Thank you !

J0sh...
08/05/2016, 08:51 PM
Please please please use GetPlayerPoolSize() or foreach (http://forum.sa-mp.com/showthread.php?t=570868)

Slawiii
09/05/2016, 12:06 PM
@Jamester this with foreach


CMD:armourall(playerid, params[])
{
new str[128];
if(pInfo[playerid][Logged] == 0) return SendClientMessage(playerid, COLOR_RED, "[Error]: You must be logged in!");
if(pInfo[playerid][Admin] >= 4)
{
SendAdminCMD(playerid, "armourall", 0);
foreach(new p: Player)
{
if(IsPlayerConnected(p) && InDM[p] == 0)
{
PlayerPlaySound(p, 1057, 0.0, 0.0, 0.0);
SetPlayerArmour(p, 100.0);
}
}
PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
format(str, sizeof(str), "Administrator %s(%d) has armoured all players!", GetName(playerid), playerid);
SendClientMessageToAll(COLOR_YELLOW, str);
}
else return SendClientMessage(playerid, COLOR_RED, EACMD);
return 1;
}

EDITED: Removed OnPlayerConnect(p) because with foreach as it loops through connected players only. ( Thanks to Konstantinos )

CMD:armourall(playerid, params[])
{
new str[128];
if(pInfo[playerid][Logged] == 0) return SendClientMessage(playerid, COLOR_RED, "[Error]: You must be logged in!");
if(pInfo[playerid][Admin] >= 4)
{
SendAdminCMD(playerid, "armourall", 0);
foreach(new p: Player)
{
//if(IsPlayerConnected(p) && InDM[p] == 0)
if(InDM[p] == 0)
{
PlayerPlaySound(p, 1057, 0.0, 0.0, 0.0);
SetPlayerArmour(p, 100.0);
}
}
PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
format(str, sizeof(str), "Administrator %s(%d) has armoured all players!", GetName(playerid), playerid);
SendClientMessageToAll(COLOR_YELLOW, str);
}
else return SendClientMessage(playerid, COLOR_RED, EACMD);
return 1;
}

Konstantinos
09/05/2016, 12:28 PM
Do not check if player is connected with foreach as it loops through connected players only.

Slawiii
09/05/2016, 01:09 PM
Do not check if player is connected with foreach as it loops through connected players only.

Yes, thanks you :D