SA-MP Forums Archive
Need help for this command - 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: Need help for this command (/showthread.php?tid=434381)



Need help for this command - Nubik - 02.05.2013

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;
}



Re : Need help for this command - DaTa[X] - 02.05.2013

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]);
}



Re: Need help for this command - Nubik - 02.05.2013

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


Re: Re : Need help for this command - RevolutionaryGaming - 02.05.2013

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.


Re : Re: Re : Need help for this command - DaTa[X] - 02.05.2013

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


Re: Need help for this command - Nubik - 03.05.2013

Help anyone please?


Re: Need help for this command - Nubik - 04.05.2013

Bump, no one can help?


Re: Need help for this command - Pottus - 04.05.2013

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;
}