SA-MP Forums Archive
Identify if player's vehicle is being robbed - 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: Identify if player's vehicle is being robbed (/showthread.php?tid=523281)



Identify if player's vehicle is being robbed - YwX - 01.07.2014

Hello!
Well, I have created a vehicle buy system and all is Ok.
But when someone enter in vehicle that is of another player, I want to send a message to vehicle's owner and a message to the thief.
My variable for assign an ID to the vehicle of player is:
pawn Код:
bought_vehicle[MAX_PLAYERS];
And I have a bool too:
pawn Код:
new bool:boughtveh[MAX_PLAYERS];
When the player buy the vehicle:
pawn Код:
bought_vehicle[playerid] = CreateVehicle(bla, bla, bla, bla, bla);
boughtveh[playerid] = true;
So, I need a code that when a player enter a vehicle, identify if this vehicle is of another player and, if is, send a message to the thief and to the vehicle's owner.
By the logic, is something like:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(vehicleid != bought_vehicle[playerid]) return SendClientMessage(playerid, red, "This vehicle is not yours!");
    return 1;
}
I'm having problem sending the messages. How to get the ID of the thief and send a message to him and for the vehicle owner?
Thanks all in advance!


Re: Identify if player's vehicle is being robbed - GeekSiMo - 01.07.2014

Try To Do it OnPlayerEnterVehicle, If vehicleid[owner] != playerid, SendClientMessage....


Re: Identify if player's vehicle is being robbed - YwX - 01.07.2014

Quote:
Originally Posted by GeekSiMo
Посмотреть сообщение
Try To Do it OnPlayerEnterVehicle, If vehicleid[owner] != playerid, SendClientMessage....
I can't do by this way:
pawn Код:
if(vehicleid[bought_vehicle[playerid]])



Re: Identify if player's vehicle is being robbed - YwX - 01.07.2014

Can anyone help?


Re: Identify if player's vehicle is being robbed - LivingLikeYouDo - 01.07.2014

You should make it into enums I think, so it could get the player name, as the variables won't save if the server is restarted.


Re: Identify if player's vehicle is being robbed - YwX - 01.07.2014

Quote:
Originally Posted by LivingLikeYouDo
Посмотреть сообщение
You should make it into enums I think, so it could get the player name, as the variables won't save if the server is restarted.
No no my friend, I don't need this. The system is complete, the player's vehicle is saved in a file.
I just need the message to be sent if who is entering in the vehicle is not the owner. But thanks for try help!


Re: Identify if player's vehicle is being robbed - YwX - 01.07.2014

Someone...?


Re: Identify if player's vehicle is being robbed - YwX - 03.07.2014

bump


Re: Identify if player's vehicle is being robbed - YwX - 04.07.2014

...no one knows how to help me?


Re: Identify if player's vehicle is being robbed - Jefff - 04.07.2014

pawn Код:
GetVehicleOwnerID(vehicleid)
{

    for(new i=0; i != MAX_PLAYERS; i++)
        if(IsPlayerConnected(i))
            if(bought_vehicle[i] == vehicleid)
                return i;

    return INVALID_PLAYER_ID;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(vehicleid != bought_vehicle[playerid])
    {
        new owner = GetVehicleOwnerID(vehicleid);
        if(owner != INVALID_PLAYER_ID)
        {
            // thief
            SendClientMessage(playerid, red, "This vehicle is not yours!");

            // owner part
            new thief[MAX_PLAYER_NAME],str[128];
            GetPlayerName(playerid,thief,sizeof(thief));
            format(str,sizeof(str),"%s (ID: %d) bla bla",thief,playerid);
            SendClientMessage(owner, red, str);
            return 0;
        }
    }
    return 1;
}