SA-MP Forums Archive
Registering a car to a players name - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Registering a car to a players name (/showthread.php?tid=184287)



Registering a car to a players name - CSMajor - 19.10.2010

How can i achieve this? i just am so nooby i cant think of how i might achieve this



I want to make it so it stores the values etc. and sends a message if its the wrong user.



tried doing

enum cInfo
{

CarID
CarOwner
}


but i cant figure out how to do that


Re: Registering a car to a players name - CSMajor - 19.10.2010

please help me get started?


Re: Registering a car to a players name - NewYorkRP - 19.10.2010

I recommend downloading a script that already has this "function", downloading it, going to the main process and having a look.

This will;

- Improve your scripting knowledge...

Have a search around. .


Re: Registering a car to a players name - Sascha - 19.10.2010

you can also do it this way (this is a kinda stupid and long way, however you can learn it by using this at the beginning)

imagine the player is called: Peter

at the top of your script:
Код:
new peter;
then at the vehicle you want to assign to peter:
Код:
peter = AddStaticVehicle(................);
and now search "OnPlayerStateChange" in your script and write:
Код:
new v = GetPlayerVehicleID(playerid);
if(newstate == PLAYER_STATE_DRIVER && oldstate == PLAYER_STATE_ONFOOT){
 if(v = peter){
  new owner[50]; 
  GetPlayerName(playerid, owner, 50);
  if(!strcmp(owner, "Peter", true)){
   SendClientMessage(playerid, YOURCOLOR, "This vehicle is assigned to you");
  }else{
   RemovePlayerFromVehicle(playerid);
   SendClientMessage(playerid, YOURCOLOR, "This vehicle belongs to Peter");
  }
 }
 return 1;
}
as the "peter" has now the ID of the vehicle, you can check whether the vehicle the player just entered has the same ID as peter and if it has it is the vehicle you assigned to Peter.
then you get the name of the player and check whether the name is = "Peter" and if it is it will send a message to Peter that this vehicle is assigned to him...
if it is not Peter the player will get a message which tells him that the vehicle belongs to Peter and will remove him from the vehicle...

I hope I could help you a bit:P


Re: Registering a car to a players name - Cameltoe - 19.10.2010

Your actually onto something !
pawn Код:
// The enum:
enum cInfo
{
     CarModel,
     CarOwner[50],
}
// The symbol:
new CarInfo[MAX_VEHICLES][cInfo];

// OnGameModeInit

for(new vehicleid; vehicleid < MAX_VEHICLES; vehicleid++)
{
     strmid(CarInfo[vehicleid][CarOwner], "CarOwner", 0, 50, 50);
}
This should get you going, with a little help from what Sascha made


Re: Registering a car to a players name - CSMajor - 19.10.2010

Quote:
Originally Posted by Sascha
Посмотреть сообщение
you can also do it this way (this is a kinda stupid and long way, however you can learn it by using this at the beginning)

imagine the player is called: Peter

at the top of your script:
Код:
new peter;
then at the vehicle you want to assign to peter:
Код:
peter = AddStaticVehicle(................);
and now search "OnPlayerStateChange" in your script and write:
Код:
new v = GetPlayerVehicleID(playerid);
if(newstate == PLAYER_STATE_DRIVER && oldstate == PLAYER_STATE_ONFOOT){
 if(v = peter){
  new owner[50]; 
  GetPlayerName(playerid, owner, 50);
  if(!strcmp(owner, "Peter", true)){
   SendClientMessage(playerid, YOURCOLOR, "This vehicle is assigned to you");
  }else{
   RemovePlayerFromVehicle(playerid);
   SendClientMessage(playerid, YOURCOLOR, "This vehicle belongs to Peter");
  }
 }
 return 1;
}
as the "peter" has now the ID of the vehicle, you can check whether the vehicle the player just entered has the same ID as peter and if it has it is the vehicle you assigned to Peter.
then you get the name of the player and check whether the name is = "Peter" and if it is it will send a message to Peter that this vehicle is assigned to him...
if it is not Peter the player will get a message which tells him that the vehicle belongs to Peter and will remove him from the vehicle...

I hope I could help you a bit:P
Ah thanks for that but, thats not what i need. I have made my own car dealership, but i do no know how to set ownership to players who buy the cars -.-


Re: Registering a car to a players name - Cameltoe - 19.10.2010

You should probably look into an custom vehicle ownership before trying on your own, look at the post i made, describes how to insert an string into the CarOwner variable.

Also searching can help you out as others also struggled with similar problems.


Re: Registering a car to a players name - CSMajor - 19.10.2010

Quote:
Originally Posted by Cameltoe
Посмотреть сообщение
Your actually onto something !
pawn Код:
// The enum:
enum cInfo
{
     CarModel,
     CarOwner[50],
}
// The symbol:
new CarInfo[MAX_VEHICLES][cInfo];

// OnGameModeInit

for(new vehicleid; vehicleid < MAX_VEHICLES; vehicleid++)
{
     strmid(CarInfo[vehicleid][CarOwner], "CarOwner", 0, 50, 50);
}
This should get you going, with a little help from what Sascha made
Please explain what it does?


Re: Registering a car to a players name - Cameltoe - 19.10.2010

Quote:
Originally Posted by Cameltoe
Посмотреть сообщение
You should probably look into an custom vehicle ownership before trying on your own, look at the post i made, describes how to insert an string into the CarOwner variable.

Also searching can help you out as others also struggled with similar problems.
pawn Код:
// The enum:
enum cInfo
{
     CarModel,
     CarOwner[50],
}
// The symbol:
new CarInfo[MAX_VEHICLES][cInfo];

// OnGameModeInit

for(new vehicleid; vehicleid < MAX_VEHICLES; vehicleid++)
{
     strmid(CarInfo[vehicleid][CarOwner], "CarOwner", 0, 50, 50);
}
Inserts the "CarOwner" string into the CarOwner variable.

This is just an example .. but should get you going.

use some printf's to experiment.


Re: Registering a car to a players name - CSMajor - 19.10.2010

I dont understand this advanced crap.... im on a amatureish intermediate level



and i cant find any script thats clear to read


Re: Registering a car to a players name - CSMajor - 19.10.2010

I must be stupid......... I cant figure this damn thing out -.- its .... Pissing me off.


Re: Registering a car to a players name - Cameltoe - 19.10.2010

Quote:
Originally Posted by CSMajor
Посмотреть сообщение
I must be stupid......... I cant figure this damn thing out -.- its .... Pissing me off.
Nothing to do with stupidity it's just a lack of pawn knowledge.. if you'r completely new, try reading some tutorials.

Also this tutorial: http://forum.sa-mp.com/showthread.ph...ighlight=house

Is an house tutorial though.. but car owner and house would be pretty much the same.