SA-MP Forums Archive
WhaT? -.- - 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: WhaT? -.- (/showthread.php?tid=454797)



WhaT? -.- - RandomDude - 30.07.2013

pawn Код:
if(GetClosestPlayerToPlayer(playerid,ID) > RAPE_DISTANCE) return SendClientMessage(playerid, RED, "You are not close enough to eachother!");
Код:
warning 202: number of arguments does not match definition
pawn Код:
forward GetClosestPlayerToPlayer(playerid);
public GetClosestPlayerToPlayer(playerid)
{
    new Float:dist = 1000.0;
    new targetid = INVALID_PLAYER_ID;
    new Float:x1,Float:y1,Float:z1;
    new Float:x2,Float:y2,Float:z2;
    new Float:tmpdis;
    GetPlayerPos(playerid,x1,y1,z1);
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        if(i == playerid) continue;
        GetPlayerPos(i,x2,y2,z2);
        tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
        if(tmpdis < dist)
        {
            dist = tmpdis;
            targetid = i;
        }
    }
    return targetid;
}
pawn Код:
dcmd_rape(playerid, params[])
{
        new ID = strval(params);
        if(!strlen(params))
        {
                SendClientMessage(playerid, RED, "USAGE: /rape [ID]");
        }
        else
        {
                if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, RED, "That player is not connected!");
                if(ID == playerid) return SendClientMessage(playerid, RED, "You cannot rape yourself!");
                if(rapespam[playerid] == 0)
                {
                        if(GetClosestPlayerToPlayer(playerid,ID) > RAPE_DISTANCE) return SendClientMessage(playerid, RED, "NO one close.");



Re: WhaT? -.- - thimo - 30.07.2013

GetClosestPlayerToPlayer(playerid,ID) This defenition does not match with what you used:
Код:
public GetClosestPlayerToPlayer(playerid)
Try this maybe:
Код:
GetClosestPlayerToPlayer(ID)



Re: WhaT? -.- - dEcooR - 30.07.2013

Код:
if(GetClosestPlayerToPlayer(playerid,ID) > RAPE_DISTANCE) return SendClientMessage(playerid, RED, "You are not close enough to eachother!");



Re: WhaT? -.- - RandomDude - 30.07.2013

Quote:
Originally Posted by thimo
Посмотреть сообщение
GetClosestPlayerToPlayer(playerid,ID) This defenition does not match with what you used:
Код:
public GetClosestPlayerToPlayer(playerid)
Try this maybe:
Код:
GetClosestPlayerToPlayer(ID)
I still get the warning...
But this is also a fix thanks :P


Код:
warning 202: number of arguments does not match definition
pawn Код:
if(GetClosestPlayerToPlayer(playerid,ID) > RAPE_DISTANCE) return SendClientMessage(playerid, RED, "NO one close.");



Re: WhaT? -.- - doreto - 30.07.2013

don't you see the difference
public GetClosestPlayerToPlayer(playerid) - how it should be
GetClosestPlayerToPlayer(playerid,ID)


Re: WhaT? -.- - thimo - 30.07.2013

So what fixed the problem?


Re: WhaT? -.- - dEcooR - 30.07.2013

sorry i wrote it bad .. it should be like this

Код:
if(GetClosestPlayerToPlayer(playerid) > RAPE_DISTANCE) return SendClientMessage(playerid, RED, "You are not close enough to eachother!");



Re: WhaT? -.- - thimo - 30.07.2013

I dont think its like this... Doesnt make any sense to me dEcooR since he has a custom variable and then he just doesnt use it...


Re: WhaT? -.- - CrazyChoco - 30.07.2013

How could your function be:

pawn Код:
stock GetClosestPlayerToPlayer(playerid)
{
    new Float:dist = 1000.0;
    new targetid = INVALID_PLAYER_ID;
    new Float:x1,Float:y1,Float:z1;
    new Float:x2,Float:y2,Float:z2;
    new Float:tmpdis;
    GetPlayerPos(playerid,x1,y1,z1);
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        if(i == playerid) continue;
        GetPlayerPos(i,x2,y2,z2);
        tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
        if(tmpdis < dist)
        {
            dist = tmpdis;
            targetid = i;
        }
    }
    return targetid;
}
When you paste this into your command:


pawn Код:
if(GetClosestPlayerToPlayer(playerid,ID) > RAPE_DISTANCE) return SendClientMessage(playerid, RED, "NO one close.");
Look close at this:

Function: GetClosestPlayerToPlayer(playerid)
Command: GetClosestPlayerToPlayer(playerid,ID)

You should see your problem now I think.



EDIT: Too late before new posts..


Re: WhaT? -.- - RandomDude - 30.07.2013

Quote:
Originally Posted by doreto
Посмотреть сообщение
don't you see the difference
public GetClosestPlayerToPlayer(playerid) - how it should be
GetClosestPlayerToPlayer(playerid,ID)
This worked thanks.