[REQUEST] Test
#1

I need help :P

can someone test this sctipt for me im not sure if it works:

PS. I cant test this script on myself >.<

pawn Код:
#include <a_samp>

forward PoisonedPlayer(playerid);
new Poisoned[MAX_PLAYERS];

public OnFilterScriptInit()
{
    SetTimer("PoisonedPlayer",30000,true);
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    Poisoned[playerid] = 0;
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256], idx, tmp[256];
    cmd = strtok(cmdtext, idx);

    new targetid = strval(tmp);
    tmp = strtok(cmdtext, idx);

    new pName [MAX_PLAYER_NAME], tName [MAX_PLAYER_NAME], string [128];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    GetPlayerName(targetid, tName, MAX_PLAYER_NAME);
   
   
    if (strcmp("/apoison", cmdtext, true, 10) == 0)
    {
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFF303EAA,"Your not an admin!");
        if(!strlen(tmp)) return SendClientMessage(playerid,0xFF303EAA,"UASGE: /apoison [ID]");
        if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,0xFF303EAA,"Player is not connected");

        format (string, sizeof(string), "Admin %s(%d) has poisoned %s(%d)", pName, playerid, tName, targetid);
        SendClientMessageToAll(0xA9A9A9FF, string);

        Poisoned[targetid] = 1;
        return 1;
    }
    return 0;
}

public PoisonedPlayer(playerid)
{
    new Float:health;
    GetPlayerHealth(playerid, health);

    if(Poisoned[playerid] == 1)
    {
        SetPlayerHealth(playerid, health-5);
    }
}

strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
Reply
#2

Why when a player is death, Poisoned changed to 0?
That way If he got killed or died somehow, HE will be release out of jail.
Reply
#3

it compiles, but the server wont work, you forgot the
Код:
main{}()
also the poisoned playerS (could be any ID) needs to be in a loop (Timer Callback), to make it work for all:
Код:
public PoisonedPlayer(playerid)
{
	new Float:health;
	for(new ID=0;ID<MAX_PLAYERS;ID++)
	{
		if(Poisoned[ID] == 1)
		{
			GetPlayerHealth(ID, health);
			SetPlayerHealth(ID, health-5);
		}
	}
	return 1;
}
Reply
#4

fuck. delete this plz ^^
Код:
for(new shame=0;shame<100;shame++)
{
SendClientMessageToAll(0xff00ffff,"i wont click 'reply' when i want to 'edit'");
}
Reply
#5

Well Thanks :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)