Need help for this command
#1

Can anyone help me with this command i want it to work without typing player id for example: /rape instead of /rape id and if possible convert it to zcmd please and thank you

pawn Код:
dcmd_rape(playerid, params[])
{
    new ID = strval(params);
    if(!strlen(params))
    {
        SendClientMessage(playerid, COLOR_ERROR, "USAGE: /rape [ID]");
    }
    else
    {
        if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_ERROR, "That player is not connected!");
        if(ID == playerid) return SendClientMessage(playerid, COLOR_ERROR, "You cannot rape yourself!");
        if(rapespam[playerid] == 0)
        {
            if(GetDistanceBetweenPlayers(playerid,ID) > RAPE_DISTANCE) return SendClientMessage(playerid, COLOR_ERROR, "You are not close enough to eachother!");
            new raperand = random(5);
            if(raperand == 1 || raperand == 2)
            {
                format(string, sizeof(string), "%s (%i) noticed you trying to rape him", ReturnPlayerName(ID), ID);
                SendClientMessage(playerid, COLOR_MSG, string);
                format(string, sizeof(string), "%s (%i) tried to rape you", ReturnPlayerName(playerid), playerid);
                SendClientMessage(ID, COLOR_MSG, string);
            }
            else if(raperand == 3 || raperand == 5)
            {
                if(!chlamydia[ID])
                {
                    chlamydia[ID] = 1;
                    new Float:health;
                    GetPlayerHealth(ID, health);
                    SetPlayerHealth(ID, health-5-random(10));
                    format(string, 256, "You raped and infected %s (%i) with Chlamydia", ReturnPlayerName(ID), ID);
                    SendClientMessage(playerid, COLOR_MSG, string);
                    format(string, sizeof(string), "%s (%i) raped you and infected you with Chlamydia", ReturnPlayerName(playerid), playerid);
                    SendClientMessage(ID, COLOR_MSG, string);
                }
                else
                {
                    new Float:health;
                    GetPlayerHealth(ID, health);
                    SetPlayerHealth(ID, health-5-random(15));
                    format(string, 256, "You raped %s (%i)", ReturnPlayerName(ID), ID);
                    SendClientMessage(playerid, COLOR_MSG, string);
                    format(string, sizeof(string), "%s (%i) raped you", ReturnPlayerName(playerid), playerid);
                    SendClientMessage(ID, COLOR_MSG, string);
                }
            }
            else if(raperand == 4)
            {
                if(!gonorrhea[ID])
                {
                    gonorrhea[ID] = 1;
                    new Float:health;
                    GetPlayerHealth(ID, health);
                    SetPlayerHealth(ID, health-5-random(20));
                    format(string, 256, "You raped and infected %s (%i) with Gonorrhea", ReturnPlayerName(ID), ID);
                    SendClientMessage(playerid, COLOR_MSG, string);
                    format(string, sizeof(string), "%s (%i) raped you and infected you with Gonorrhea", ReturnPlayerName(playerid), playerid);
                    SendClientMessage(ID, COLOR_MSG, string);
                }
                else
                {
                    new Float:health;
                    GetPlayerHealth(ID, health);
                    SetPlayerHealth(ID, health-5-random(20));
                    format(string, 256, "You raped %s (%i)", ReturnPlayerName(ID), ID);
                    SendClientMessage(playerid, COLOR_MSG, string);
                    format(string, sizeof(string), "%s (%i) raped you", ReturnPlayerName(playerid), playerid);
                    SendClientMessage(ID, COLOR_MSG, string);
                }
            }
            rapespam[playerid] = 1;
            SetTimerEx("rapespamt", ANTISPAM_RAPE*1000, false, "i", playerid);
        }
        else
        {
        SendClientMessage(playerid, COLOR_ERROR, "Please wait before raping someone again!");
        }
    }
    return 1;
}
Reply
#2

pawn Код:
stock Float:GetPlayerDistanceFromPlayer(playerid, targetid)
{
    new Float:fDist[3];
    GetPlayerPos(playerid, fDist[0], fDist[1], fDist[2]);
    return GetPlayerDistanceFromPoint(targetid, fDist[0], fDist[1], fDist[2]);
}
Reply
#3

Not working, command doing nothing, no messages when i type /rape , but if i type /rape "player id" then it works

Here's the full script: http://pastebin.com/f8393df9
Reply
#4

Quote:
Originally Posted by DaTa[X]
Посмотреть сообщение
give this a try
pawn Код:
stock Float:GetPlayerDistanceFromPlayer(playerid, targetid)
{
    new Float:fDist[3];
    GetPlayerPos(playerid, fDist[0], fDist[1], fDist[2]);
    return GetPlayerDistanceFromPoint(targetid, fDist[0], fDist[1], fDist[2]);
}


CMD:rape(playerid, params[])
{
    new ID;
    if(sscanf(params,"u",ID))
    {
        for(new i=0; i < MAX_PLAYERS; i++){
        if(GetPlayerDistanceFromPlayer(playerid, i) < 5)
        {
            i = ID;
            break;
        } }
    }
    else
    {
        if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_ERROR, "That player is not connected!");
        if(ID == playerid) return SendClientMessage(playerid, COLOR_ERROR, "You cannot rape yourself!");
        if(rapespam[playerid] == 0)
        {
            if(GetDistanceBetweenPlayers(playerid,ID) > RAPE_DISTANCE) return SendClientMessage(playerid, COLOR_ERROR, "You are not close enough to eachother!");
            new raperand = random(5);
            if(raperand == 1 || raperand == 2)
            {
                format(string, sizeof(string), "%s (%i) noticed you trying to rape him", ReturnPlayerName(ID), ID);
                SendClientMessage(playerid, COLOR_MSG, string);
                format(string, sizeof(string), "%s (%i) tried to rape you", ReturnPlayerName(playerid), playerid);
                SendClientMessage(ID, COLOR_MSG, string);
            }
            else if(raperand == 3 || raperand == 5)
            {
                if(!chlamydia[ID])
                {
                    chlamydia[ID] = 1;
                    new Float:health;
                    GetPlayerHealth(ID, health);
                    SetPlayerHealth(ID, health-5-random(10));
                    format(string, 256, "You raped and infected %s (%i) with Chlamydia", ReturnPlayerName(ID), ID);
                    SendClientMessage(playerid, COLOR_MSG, string);
                    format(string, sizeof(string), "%s (%i) raped you and infected you with Chlamydia", ReturnPlayerName(playerid), playerid);
                    SendClientMessage(ID, COLOR_MSG, string);
                }
                else
                {
                    new Float:health;
                    GetPlayerHealth(ID, health);
                    SetPlayerHealth(ID, health-5-random(15));
                    format(string, 256, "You raped %s (%i)", ReturnPlayerName(ID), ID);
                    SendClientMessage(playerid, COLOR_MSG, string);
                    format(string, sizeof(string), "%s (%i) raped you", ReturnPlayerName(playerid), playerid);
                    SendClientMessage(ID, COLOR_MSG, string);
                }
            }
            else if(raperand == 4)
            {
                if(!gonorrhea[ID])
                {
                    gonorrhea[ID] = 1;
                    new Float:health;
                    GetPlayerHealth(ID, health);
                    SetPlayerHealth(ID, health-5-random(20));
                    format(string, 256, "You raped and infected %s (%i) with Gonorrhea", ReturnPlayerName(ID), ID);
                    SendClientMessage(playerid, COLOR_MSG, string);
                    format(string, sizeof(string), "%s (%i) raped you and infected you with Gonorrhea", ReturnPlayerName(playerid), playerid);
                    SendClientMessage(ID, COLOR_MSG, string);
                }
                else
                {
                    new Float:health;
                    GetPlayerHealth(ID, health);
                    SetPlayerHealth(ID, health-5-random(20));
                    format(string, 256, "You raped %s (%i)", ReturnPlayerName(ID), ID);
                    SendClientMessage(playerid, COLOR_MSG, string);
                    format(string, sizeof(string), "%s (%i) raped you", ReturnPlayerName(playerid), playerid);
                    SendClientMessage(ID, COLOR_MSG, string);
                }
            }
            rapespam[playerid] = 1;
            SetTimerEx("rapespamt", ANTISPAM_RAPE*1000, false, "i", playerid);
        }
        else
        {
        SendClientMessage(playerid, COLOR_ERROR, "Please wait before raping someone again!");
        }
    }
    return 1;
    }
}
You had a strong start, but for some reason you failed to actually do anything when the player was near someone. Do you the spot where you checked if the player was near anyone? Within those braces is where you need to place all of the action that occurs.
Reply
#5

Quote:
Originally Posted by RevolutionaryGaming
Посмотреть сообщение
You had a strong start, but for some reason you failed to actually do anything when the player was near someone. Do you the spot where you checked if the player was near anyone? Within those braces is where you need to place all of the action that occurs.
i'm not fixing the command i'm giving an example
Reply
#6

Help anyone please?
Reply
#7

Bump, no one can help?
Reply
#8

No need for a useless timer use GetTickCount() it is much better.

pawn Код:
stock Float:GetPlayerDistanceFromPlayer(playerid, targetid)
{
    new Float:fDist[3];
    GetPlayerPos(playerid, fDist[0], fDist[1], fDist[2]);
    return GetPlayerDistanceFromPoint(targetid, fDist[0], fDist[1], fDist[2]);
}

CMD:rape(playerid, params[])
{

    if(GetTickCount() - rapespam[playerid] < ANTISPAM_RAPE*1000) SendClientMessage(playerid, COLOR_ERROR, "Please wait before raping someone again!");
    else
    {
        new ID;
        sscanf(params,"u",ID);

        if(ID != INVALID_PLAYER_ID)
        {
            if(ID == playerid) SendClientMessage(playerid, COLOR_ERROR, "You cannot rape yourself!");
            else
            {
                if(GetPlayerDistanceFromPlayer(playerid, ID) > 5.0) SendClientMessage(playerid, COLOR_ERROR, "You are not close enough to that player!");
                else
                {
                    new raperand = random(5);
                    if(raperand == 1 || raperand == 2)
                    {
                        format(string, sizeof(string), "%s (%i) noticed you trying to rape him", ReturnPlayerName(ID), ID);
                        SendClientMessage(playerid, COLOR_MSG, string);
                        format(string, sizeof(string), "%s (%i) tried to rape you", ReturnPlayerName(playerid), playerid);
                        SendClientMessage(ID, COLOR_MSG, string);
                    }
                    else
                    {
                        new Float:health;
                        GetPlayerHealth(ID, health);

                        if(raperand == 3 || raperand == 5)
                        {
                            if(!chlamydia[ID])
                            {
                                chlamydia[ID] = 1;
                                SetPlayerHealth(ID, health-5-random(10));
                                format(string, 256, "You raped and infected %s (%i) with Chlamydia", ReturnPlayerName(ID), ID);
                                SendClientMessage(playerid, COLOR_MSG, string);
                                format(string, sizeof(string), "%s (%i) raped you and infected you with Chlamydia", ReturnPlayerName(playerid), playerid);
                            }
                            else
                            {
                                SetPlayerHealth(ID, health-5-random(15));
                                format(string, 256, "You raped %s (%i)", ReturnPlayerName(ID), ID);
                                SendClientMessage(playerid, COLOR_MSG, string);
                                format(string, sizeof(string), "%s (%i) raped you", ReturnPlayerName(playerid), playerid);
                            }
                        }
                        else if(raperand == 4)
                        {
                            if(!gonorrhea[ID])
                            {
                                gonorrhea[ID] = 1;
                                SetPlayerHealth(ID, health-5-random(20));
                                format(string, 256, "You raped and infected %s (%i) with Gonorrhea", ReturnPlayerName(ID), ID);
                                SendClientMessage(playerid, COLOR_MSG, string);
                                format(string, sizeof(string), "%s (%i) raped you and infected you with Gonorrhea", ReturnPlayerName(playerid), playerid);
                            }
                            else
                            {
                                SetPlayerHealth(ID, health-5-random(20));
                                format(string, 256, "You raped %s (%i)", ReturnPlayerName(ID), ID);
                                SendClientMessage(playerid, COLOR_MSG, string);
                                format(string, sizeof(string), "%s (%i) raped you", ReturnPlayerName(playerid), playerid);
                            }
                        }
                        SendClientMessage(ID, COLOR_MSG, string);
                        rapespam[playerid] = GetTickCount();
                    }
                }
            }
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)