car keys giving rep - 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: car keys giving rep (
/showthread.php?tid=495240)
car keys giving rep -
iBots - 16.02.2014
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...
Re: car keys giving rep -
Abreezy - 16.02.2014
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.
Re: car keys giving rep -
Dignity - 16.02.2014
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;
}
Re: car keys giving rep -
iBots - 16.02.2014
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.
Re: car keys giving rep -
Dignity - 16.02.2014
Multipe player variables.
Carkey1, Carkey2(

)
Re: car keys giving rep -
NovaGaming - 16.02.2014
Quote:
Originally Posted by Mionee
Multipe player variables.
Carkey1, Carkey2(  )
|
Good idea