car keys giving rep
#1

I have tried alot of times to make givekey command which is if you got a car and you are in it ,you write the player id of the guy you want to give and he can /lock your car but you can give more than 1 guy the access,the same like the Rp servers../givekey,please help.
I am using strcmp...
Reply
#2

You need to show your /lock command in order to get the variable which allows access to the lock door. Show me this and I'll help out.
Reply
#3

I highly suggest you to use ZCMD and SSCANF. It will make your life so much easier. I have written an example for you below (using zCMD and SSCANF) to show the effectiveness and a snippet of how you could do it. If you are determinant that you want strcmp, I'm willing to re-write said code from zcmd to strcmp.

pawn Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>

new CarOwner[MAX_PLAYERS];
new CarKey[MAX_PLAYERS];
new CarKeyInvite[MAX_PLAYERS];

CMD:givekey(playerid, params[])
{
    new vehicle, targetid, name[MAX_PLAYER_NAME], string[128];

    vehicle = GetPlayerVehicleID(playerid);
    GetPlayerName(playerid, name, sizeof(name));

    if(IsPlayerInAnyVehicle(playerid))
    {
        if(CarOwner[playerid] == vehicle) // whatever you use for car owner var
        {
            if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, 0xFFFFFFF, "/carkey [playerid]");

            CarKeyInvite[targetid] = vehicle; // set their invite to the vehicle ID

            format(string, sizeof(string), "You have been offered a car key (car ID %d) from %s! Type /acceptcarkey to accept it!", vehicle, name);
            return 1;
        }
        else SendClientMessage(playerid, -1, "You don't own this vehicle!");
    }
    else SendClientMessage(playerid, -1, "You need to be in a vehicle to do this command!");
    return 1;
}

CMD:acceptkey(playerid, params[])
{
    new string[128], vehicle;
    vehicle = GetPlayerVehicleID(playerid);

    if(CarKeyInvite[playerid] >= 0)
    {
        CarKey[playerid] = CarKeyInvite[playerid]; // set their invite (aka car ID) to car key
        CarKeyInvite[playerid] = 0; // Reset their invite)

        format(string, sizeof(string), "You have accepted a car key (car ID %d)! You can now manage it!", vehicle);
        return 1;
    }
    else SendClientMessage(playerid, -1, "You need to be in a vehicle to do this command!");
    return 1;
}

CMD:lockcar(playerid, params[])
{
    new vehicle;
    vehicle = GetPlayerVehicleID(playerid);
   
    if(IsPlayerInAnyVehicle(playerid))
    {
        if( CarOwner[playerid] == vehicle || CarKey[playerid] == vehicle) // However you check car owners
        {
            // code here
        }
        else SendClientMessage(playerid, -1, "You don't own this car!");
    }
    else SendClientMessage(playerid, -1, "You need to be in a vehicle to do this command!");
    return 1;
}
Reply
#4

I will post my lock command abreezy
And yea,i am good at scripting but is there anyway like you can have more than 1 key on you.
Reply
#5

Multipe player variables.

Carkey1, Carkey2()
Reply
#6

Quote:
Originally Posted by Mionee
Посмотреть сообщение
Multipe player variables.

Carkey1, Carkey2()
Good idea
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)