Payday fraction - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Payday fraction (
/showthread.php?tid=651677)
Payday fraction -
EvgeniyHostel1992 - 25.03.2018
how to split the amount entered into the player of the members, who are now?
PHP код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(pl[i][pMember]==number||pl[i][pLeader]==number)
GivePlayerMoney(i ???)
}
Re: Payday fraction -
kovac - 25.03.2018
https://sampwiki.blast.hk/wiki/GivePlayerMoney
Re: Payday fraction -
XVlaDX - 25.03.2018
Код:
stock countFactionMembers(factionid)
{
new count;
foreach(Player, i)
{
if(pl[i][pMember] == factionid || pl[i][pLeader] == factionid)
{
count++;
}
}
return count;
}
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(pl[i][pMember]==number||pl[i][pLeader]==number)
{
GivePlayerMoney(i, money/countFactionMembers(number));
}
}
Re: Payday fraction -
EvgeniyHostel1992 - 25.03.2018
PHP код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(pl[i][pMember]==fidzp||pl[i][pLeader]==fidzp){
GivePlayerMoney(i,strval(inputtext)/i);}
}
- NO!
Re: Payday fraction -
EvgeniyHostel1992 - 25.03.2018
Quote:
Originally Posted by XVlaDX
Код:
stock countFactionMembers(factionid)
{
new count;
foreach(Player, i)
{
if(pl[i][pMember] == factionid || pl[i][pLeader] == factionid)
{
count++;
}
}
return count;
}
|
PHP код:
new.pwn(2195) : error 017: undefined symbol "foreach"
new.pwn(2197) : error 017: undefined symbol "i"
Re: Payday fraction -
XVlaDX - 25.03.2018
Quote:
Originally Posted by EvgeniyHostel1992
PHP код:
new.pwn(2195) : error 017: undefined symbol "foreach"
new.pwn(2197) : error 017: undefined symbol "i"
|
Include the foreach library
Re: Payday fraction -
kovac - 25.03.2018
What are you trying to do?
Re: Payday fraction -
EvgeniyHostel1992 - 25.03.2018
divide(split) the amount of money you enter for your gang players who are online
Re: Payday fraction -
kovac - 25.03.2018
Try this:
PHP код:
stock countFactionMembers(factionid)
{
new count;
foreach (new i : Player)
{
if(pl[i][pMember] == factionid || pl[i][pLeader] == factionid)
{
count++;
}
}
return count;
}
I'm not sure what "number" is so I left it as it was
PHP код:
new amount = strval(inputtext)
foreach (new i : Player)
{
if(pl[i][pMember]==number||pl[i][pLeader]==number)
{
GivePlayerMoney(i, amount/2);
}
}
Hope this will help you
EDIT: I assume that you already have included foreach.
Re: Payday fraction -
XVlaDX - 25.03.2018
Quote:
Originally Posted by kovac
Try this:
PHP код:
stock countFactionMembers(factionid)
{
new count;
foreach (new i : Player)
{
if(pl[i][pMember] == factionid || pl[i][pLeader] == factionid)
{
count++;
}
}
return count;
}
I'm not sure what "number" is so I left it as it was
PHP код:
new amount = strval(inputtext)
foreach (new i : Player)
{
if(pl[i][pMember]==number||pl[i][pLeader]==number)
{
GivePlayerMoney(i, amount/2);
}
}
Hope this will help you
EDIT: I assume that you already have included foreach.
|
That wouldn't satisfy his requirements. You're dividing the amount of money entered by 2 instead of the number of online faction members. & I'm not sure why you included countFactionMembers if you're not going to use it in your command.