Registering a car to a players name
#1

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
Reply
#2

please help me get started?
Reply
#3

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. .
Reply
#4

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
Reply
#5

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
Reply
#6

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 -.-
Reply
#7

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.
Reply
#8

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?
Reply
#9

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.
Reply
#10

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



and i cant find any script thats clear to read
Reply
#11

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

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)