/surf command
#1

Hi, so i wanted to make a vip command /surf that loops through players to see if they are surfing the vehicle in question and removes them from it. Youll get a better idea of what i mean from the code (hopefully lol). It uses zcmd.

pawn Код:
COMMAND:surf(playerid,params[])
{
    if(IsPlayerVipMember(playerid))
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            for(new i; i <= 49; i++)
            {
                if(GetPlayerSurfingVehicleID(i) == GetPlayerVehicleID(playerid))
                {
                    SetPlayerVelocity(i,0.3,0.0,0.3);
                }
            }
        }
        else return SendClientMessage(playerid,Lred,"Error You Are Not In A Vehicle");
    }
    else return SendClientMessage(playerid,Lred,"Error You Are Not Vip");
    return 1;
}
I tryed to keep it simple don't get why its not working. Btw the loop is 49 as the server its going on is set to 50 players.
Thanks in advance.
Reply
#2

Is the funktion GetPlayerSurfingVehicleID one you've defined`?
Reply
#3

Quote:
Originally Posted by [DK]JaloNik
Посмотреть сообщение
Is the funktion GetPlayerSurfingVehicleID one you've defined`?
/facepalm.
https://sampwiki.blast.hk/wiki/GetPlayerSurfingVehicleID

On-topic:
Do loop of 50, it starts with 0 and ends with 49.


What exactly isn't working? It doesn't throw them of the vehicle?
Reply
#4

Quote:
Originally Posted by Hiddos
Посмотреть сообщение
On-topic:
Do loop of 50, it starts with 0 and ends with 49.
This also starts with 0 and ends with 49. <= 49 is the same as < 50.

pawn Код:
for(new i; i <= 49; i++)
Are you sure the bug is not in the IsPlayerVipMember(playerid) function?

If it works fine, try setting bigger velocity values and see what happens.
Reply
#5

The vip function works fine. And yes the problem is it isn't throwing them off the vehicle and the loop should be fine as when it hits 49 thats the 50th playerid (i know this could backfire but we dont get 50players yet so for now its fine).
So do you think i should setplayerpos or something? for me i cant understand why its not working.
The vip function is supplied with LuxAdmin and is tested on many other FS ive made.

Someone have an ideas? Thanks in advance.
Reply
#6

Yeah the problem is in the SA-MP's surfing code, it doesn't want to let the player fall from the vehicle's roof. Try SetPlayerPos, maybe that'll work. Or freeze the player for some seconds.
Reply
#7

Ok thanks finn ill try that cant test for a couple of hours so if anyone else has any ideas id be greatfull.
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)