Problem with this cmd:
#1

pawn Код:
CMD:rape(playerid, params[])
{
    if(gTeam[playerid] == TEAM_COP) return SendClientMessage(playerid, red, "Cops can't rape other players!");
    if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,red,"You can't rape a player if you are in a vehicle!");
    if(IsSpawned[playerid] == 0) return SendClientMessage(playerid,0xFF0000FF,"You can't use this command when you are dead or spawning.");
    if(GetPVarInt(playerid,"RapeTime")>GetTickCount())return SendClientMessage(playerid,0xFF0000FF,"Please wait 10 seconds before rape again.");
    if (GetDistanceBetweenPlayers(playerid, id)>2) return SendClientMessage(playerid, red, "You're too far away from that player.");
    {
        SendClientMessage(playerid, COLOR_WHITE, "Raped player.");
    }
    else
    {
        SendClientMessage(playerid, COLOR_WHITE, "You are NOT near a player so you can't attemp to rape him.");
        SetPVarInt(playerid,"RapeTime",GetTickCount()+10000);
    }
    return 1;
}
Function:

pawn Код:
stock GetDistanceBetweenPlayers(playerid, playerid2)
{
    new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
    new Float:tmpdis;
    GetPlayerPos(playerid,x1,y1,z1);
    GetPlayerPos(playerid2,x2,y2,z2);
    tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
    return floatround(tmpdis);
}
error 017: undefined symbol "id"
error 029: invalid expression, assumed zero

What's wrong?
Reply
#2

Change id to playerid2
Reply
#3

Still this:

error 029: invalid expression, assumed zero

Line error:
pawn Код:
else
Reply
#4

pawn Код:
new derp = GetDistanceBetweenPlayers(playerid, id);
if(derp > 2)
{
    SendClientMessage(playerid, COLOR_WHITE, "You are NOT near a player so you can't attemp to rape him.");
    SetPVarInt(playerid,"RapeTime",GetTickCount()+10000);
}
else
{
    SendClientMessage(playerid, COLOR_WHITE, "Raped player.");
}
return 1;
If you re-read your code, you are asking the script if the distance is over 2. ( > 2 ). It returns a message.
Then, it continues, as if it's not OVER 2. Meaning it's close to the player.. That's fine

BUT THEN, you put 'else'. But you already returned a message if it's over 2. So it doesn't make sense.
Reply
#5

pawn Код:
CMD:rape(playerid, params[])
{
    if(gTeam[playerid] == TEAM_COP) return SendClientMessage(playerid, red, "Cops can't rape other players!");
    if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,red,"You can't rape a player if you are in a vehicle!");
    if(IsSpawned[playerid] == 0) return SendClientMessage(playerid,0xFF0000FF,"You can't use this command when you are dead or spawning.");
    if(GetPVarInt(playerid,"RapeTime")>GetTickCount())return SendClientMessage(playerid,0xFF0000FF,"Please wait 10 seconds before rape again.");
    if (GetDistanceBetweenPlayers(playerid,playerid2)>2) return SendClientMessage(playerid, red, "You are NOT near something to attempt to rape");
    if(GetDistanceBetweenPlayers(playerid,playerid2)<2)
    {
        SendClientMessage(playerid, COLOR_WHITE, "Raped player.");
        SetPVarInt(playerid,"RapeTime",GetTickCount()+10000);
    }
    return 1;
}
Reply
#6

Quote:
Originally Posted by Tanush123
Посмотреть сообщение
pawn Код:
CMD:rape(playerid, params[])
{
    if(gTeam[playerid] == TEAM_COP) return SendClientMessage(playerid, red, "Cops can't rape other players!");
    if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,red,"You can't rape a player if you are in a vehicle!");
    if(IsSpawned[playerid] == 0) return SendClientMessage(playerid,0xFF0000FF,"You can't use this command when you are dead or spawning.");
    if(GetPVarInt(playerid,"RapeTime")>GetTickCount())return SendClientMessage(playerid,0xFF0000FF,"Please wait 10 seconds before rape again.");
    if (GetDistanceBetweenPlayers(playerid,playerid2)>2) return SendClientMessage(playerid, red, "You are NOT near something to attempt to rape");
    if(GetDistanceBetweenPlayers(playerid,playerid2)<2)
    {
        SendClientMessage(playerid, COLOR_WHITE, "Raped player.");
        SetPVarInt(playerid,"RapeTime",GetTickCount()+10000);
    }
    return 1;
}
error 017: undefined symbol "playerid2"
error 017: undefined symbol "playerid2"
Reply
#7

try
pawn Код:
CMD:rape(playerid, params[])
{
    new id;
    if(gTeam[playerid] == TEAM_COP) return SendClientMessage(playerid, red, "Cops can't rape other players!");
    if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,red,"You can't rape a player if you are in a vehicle!");
    if(IsSpawned[playerid] == 0) return SendClientMessage(playerid,0xFF0000FF,"You can't use this command when you are dead or spawning.");
    if(GetPVarInt(playerid,"RapeTime")>GetTickCount())return SendClientMessage(playerid,0xFF0000FF,"Please wait 10 seconds before rape again.");
    if (GetDistanceBetweenPlayers(playerid,id)>2) return SendClientMessage(playerid, red, "You are NOT near something to attempt to rape");
    if(GetDistanceBetweenPlayers(playerid,id)<2)
    {
        SendClientMessage(playerid, COLOR_WHITE, "Raped player.");
        SetPVarInt(playerid,"RapeTime",GetTickCount()+10000);
    }
    return 1;
}
Reply
#8

Quote:
Originally Posted by Tanush123
Посмотреть сообщение
try
pawn Код:
CMD:rape(playerid, params[])
{
    new id;
    if(gTeam[playerid] == TEAM_COP) return SendClientMessage(playerid, red, "Cops can't rape other players!");
    if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,red,"You can't rape a player if you are in a vehicle!");
    if(IsSpawned[playerid] == 0) return SendClientMessage(playerid,0xFF0000FF,"You can't use this command when you are dead or spawning.");
    if(GetPVarInt(playerid,"RapeTime")>GetTickCount())return SendClientMessage(playerid,0xFF0000FF,"Please wait 10 seconds before rape again.");
    if (GetDistanceBetweenPlayers(playerid,id)>2) return SendClientMessage(playerid, red, "You are NOT near something to attempt to rape");
    if(GetDistanceBetweenPlayers(playerid,id)<2)
    {
        SendClientMessage(playerid, COLOR_WHITE, "Raped player.");
        SetPVarInt(playerid,"RapeTime",GetTickCount()+10000);
    }
    return 1;
}
Lol now it shows just the "Raped player" message,even if i'm not near a player
Damn i'm going crazy for this little cmd.
Reply
#9

try removing new id; and changing the function to
pawn Код:
stock GetDistanceBetweenPlayers(playerid, id)
{
    new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
    new Float:tmpdis;
    GetPlayerPos(playerid,x1,y1,z1);
    GetPlayerPos(id,x2,y2,z2);
    tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
    return floatround(tmpdis);
}
Reply
#10

error 017: undefined symbol "id"

Epic.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)