SA-MP Forums Archive
How change player infection from name to numbers - 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: How change player infection from name to numbers (/showthread.php?tid=628009)



How change player infection from name to numbers - henkas - 04.02.2017

Hi!
I need your help guys so i want remake this script
Код:
format(zmstring,sizeof(zmstring), ""chat""COL_PINK" %s has been infected by %s",PlayerName(victimid),PlayerName(playerid));
										SendClientMessageToAll(-1,zmstring);
To number like (Name_Name has been infected 3 players) so its should count somehow, how much i infect players with explosion. Full code

Код:
    if(PRESSED(KEY_WALK))
	{
	if(team[playerid] == TEAM_ZOMBIE)
    {
	if(pInfo[playerid][pZombieClass] == ADVANCEDBOOMER)
	{
    if(IsPlayerInRangeOfPoint(playerid,8.0,Map[ZombieSpawnX],Map[ZombieSpawnY],Map[ZombieSpawnZ]))
    {
    GameTextForPlayer(playerid,"~r~You cant explode yourself near zombie spawn!",4000,5);
	}
	else
	{
	new victimid = GetClosestPlayer(playerid);
    new Float:x,Float:y,Float:z;
    GetPlayerPos(playerid,Float:x,Float:y,Float:z);
    SetPlayerHealth(playerid,0.0);
    CreateExplosion(Float:x,Float:y,Float:z,0,6.0);
    foreach(new i : Player)
	{
    GetClosestPlayer(i);
    if(IsPlayerConnected(i))
	{
   	switch(GetPlayerSkin(i))
    {
    case NON_IMMUNE:
	{
    if(IsPlayerInRangeOfPoint(i,7.0,Float:x,Float:y,Float:z))
	{
	if(pInfo[i][IsPlayerInfected] == 0)
	{
	new zmstring[256];
    InfectPlayerStandard(i);
    format(zmstring,sizeof(zmstring), ""chat""COL_PINK" %s has been infected by %s",PlayerName(victimid),PlayerName(playerid));
	SendClientMessageToAll(-1,zmstring);
	}



Re: How change player infection from name to numbers - Twistedz - 04.02.2017

Try this one, not tested.

Replace it instead of your current code.
Код:
if(PRESSED(KEY_WALK))
	{
	new infectedcount;
	if(team[playerid] == TEAM_ZOMBIE)
    {
	if(pInfo[playerid][pZombieClass] == ADVANCEDBOOMER)
	{
    if(IsPlayerInRangeOfPoint(playerid,8.0,Map[ZombieSpawnX],Map[ZombieSpawnY],Map[ZombieSpawnZ]))
    {
    GameTextForPlayer(playerid,"~r~You cant explode yourself near zombie spawn!",4000,5);
	}
	else
	{
	new victimid = GetClosestPlayer(playerid);
    new Float:x,Float:y,Float:z;
    GetPlayerPos(playerid,Float:x,Float:y,Float:z);
    SetPlayerHealth(playerid,0.0);
    CreateExplosion(Float:x,Float:y,Float:z,0,6.0);
    for(new i=0; i<MAX_PLAYERS; i++)
	{
    if(IsPlayerInRangeOfPoint(i,7.0,Float:x,Float:y,Float:z))
	{
	if(pInfo[i][IsPlayerInfected] == 0)
	{
	new zmstring[256],zmstring2[256],pName[MAX_PLAYER_NAME];
	infectedcount++;
    InfectPlayerStandard(i);
    GetPlayerName(playerid,pName,sizeof(pName));
    format(zmstring,sizeof(zmstring), ""chat""COL_PINK" %s has been infected by %s",PlayerName(victimid),PlayerName(playerid));
    format(zmstring2,sizeof(zmstring2),"%s has infected %i players.",pName,infectedcount);
    SendClientMessageToAll(-1,zmstring);
	SendClientMessageToAll(-1,zmstring2);
	}



Re: How change player infection from name to numbers - SyS - 05.02.2017

Quote:
Originally Posted by Twistedz
Посмотреть сообщение
Try this one, not tested.

Replace it instead of your current code.
Код:
if(PRESSED(KEY_WALK))
	{
	new infectedcount;
	if(team[playerid] == TEAM_ZOMBIE)
    {
	if(pInfo[playerid][pZombieClass] == ADVANCEDBOOMER)
	{
    if(IsPlayerInRangeOfPoint(playerid,8.0,Map[ZombieSpawnX],Map[ZombieSpawnY],Map[ZombieSpawnZ]))
    {
    GameTextForPlayer(playerid,"~r~You cant explode yourself near zombie spawn!",4000,5);
	}
	else
	{
	new victimid = GetClosestPlayer(playerid);
    new Float:x,Float:y,Float:z;
    GetPlayerPos(playerid,Float:x,Float:y,Float:z);
    SetPlayerHealth(playerid,0.0);
    CreateExplosion(Float:x,Float:y,Float:z,0,6.0);
    for(new i=0; i<MAX_PLAYERS; i++)
	{
    if(IsPlayerInRangeOfPoint(i,7.0,Float:x,Float:y,Float:z))
	{
	if(pInfo[i][IsPlayerInfected] == 0)
	{
	new zmstring[256],zmstring2[256],pName[MAX_PLAYER_NAME];
	infectedcount++;
    InfectPlayerStandard(i);
    GetPlayerName(playerid,pName,sizeof(pName));
    format(zmstring,sizeof(zmstring), ""chat""COL_PINK" %s has been infected by %s",PlayerName(victimid),PlayerName(playerid));
    format(zmstring2,sizeof(zmstring2),"%s has infected %i players.",pName,infectedcount);
    SendClientMessageToAll(-1,zmstring);
	SendClientMessageToAll(-1,zmstring2);
	}
Put the Sending part outside the loop


Re: How change player infection from name to numbers - henkas - 05.02.2017

Twist why you removed these lines?
Код:
 GetClosestPlayer(i);
    if(IsPlayerConnected(i))
	{
   	switch(GetPlayerSkin(i))
    {
    case NON_IMMUNE:
	{



Re: How change player infection from name to numbers - henkas - 05.02.2017

Quote:
Originally Posted by Twistedz
Посмотреть сообщение
Try this one, not tested.

Replace it instead of your current code.
Код:
if(PRESSED(KEY_WALK))
	{
	new infectedcount;
	if(team[playerid] == TEAM_ZOMBIE)
    {
	if(pInfo[playerid][pZombieClass] == ADVANCEDBOOMER)
	{
    if(IsPlayerInRangeOfPoint(playerid,8.0,Map[ZombieSpawnX],Map[ZombieSpawnY],Map[ZombieSpawnZ]))
    {
    GameTextForPlayer(playerid,"~r~You cant explode yourself near zombie spawn!",4000,5);
	}
	else
	{
	new victimid = GetClosestPlayer(playerid);
    new Float:x,Float:y,Float:z;
    GetPlayerPos(playerid,Float:x,Float:y,Float:z);
    SetPlayerHealth(playerid,0.0);
    CreateExplosion(Float:x,Float:y,Float:z,0,6.0);
    for(new i=0; i<MAX_PLAYERS; i++)
	{
    if(IsPlayerInRangeOfPoint(i,7.0,Float:x,Float:y,Float:z))
	{
	if(pInfo[i][IsPlayerInfected] == 0)
	{
	new zmstring[256],zmstring2[256],pName[MAX_PLAYER_NAME];
	infectedcount++;
    InfectPlayerStandard(i);
    GetPlayerName(playerid,pName,sizeof(pName));
    format(zmstring,sizeof(zmstring), ""chat""COL_PINK" %s has been infected by %s",PlayerName(victimid),PlayerName(playerid));
    format(zmstring2,sizeof(zmstring2),"%s has infected %i players.",pName,infectedcount);
    SendClientMessageToAll(-1,zmstring);
	SendClientMessageToAll(-1,zmstring2);
	}
Anyway this code full of errors


Re: How change player infection from name to numbers - henkas - 05.02.2017

warning 219: local variable "pName" shadows a variable at a preceding level
warning 209: function "RL_OnPlayerKeyStateChange" should return a value
error 054: unmatched closing brace ("}")
error 010: invalid function or declaration
error 010: invalid function or declaration
error 010: invalid function or declaration
error 010: invalid function or declaration
error 010: invalid function or declaration
error 010: invalid function or declaration
error 010: invalid function or declaration
error 010: invalid function or declaration
error 010: invalid function or declaration


Re: How change player infection from name to numbers - henkas - 05.02.2017

Well i fixed these error and warnings it was to much } and changed pName to other name because i define that variable twice.

Bat i'm not sure its will work fine.