11.07.2010, 13:43
Hi.
Im trying to do so that if you buy a vehicle at a shop, it will stick to your username, but i'm having a bit of troubles saving / checking the usernames.
Here's what i got so far, i hope someone can help me:
Buy vehicle:
new buyername[24];
GetPlayerName(playerid,buyername, 24);
boughtcar = CreateVehicle(560, 2174.2114,1421.0642,10.5913,91.0247, -1, -1, 99999999999);
BoughtCarsOwnerName[boughtcar] = buyername[0];
Here's the script where i check if username is the same as current:
Check script:
new name[256];
GetPlayerName(playerid, name, 255);
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER && BoughtCars[GetPlayerVehicleID(playerid)] == 999 && BoughtCarsOwnerName[GetPlayerVehicleID(playerid)] != name[0]) {
SendClientMessage(playerid,COLOR_YELLOW,"This car has been purchased from AutoBahn. You are not the owner");
format(string, sizeof(string), "This vehicle is registered to player: %s",BoughtCarsOwnerName[GetPlayerVehicleID(playerid)]);
SendClientMessage(playerid, COLOR_YELLOW, string);
RemovePlayerFromVehicle(playerid);
The scripts up there will return the 1 character from the string, but how the **** should i get the usernames stored in a string instead of a array?
Im trying to do so that if you buy a vehicle at a shop, it will stick to your username, but i'm having a bit of troubles saving / checking the usernames.
Here's what i got so far, i hope someone can help me:
Buy vehicle:
new buyername[24];
GetPlayerName(playerid,buyername, 24);
boughtcar = CreateVehicle(560, 2174.2114,1421.0642,10.5913,91.0247, -1, -1, 99999999999);
BoughtCarsOwnerName[boughtcar] = buyername[0];
Here's the script where i check if username is the same as current:
Check script:
new name[256];
GetPlayerName(playerid, name, 255);
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER && BoughtCars[GetPlayerVehicleID(playerid)] == 999 && BoughtCarsOwnerName[GetPlayerVehicleID(playerid)] != name[0]) {
SendClientMessage(playerid,COLOR_YELLOW,"This car has been purchased from AutoBahn. You are not the owner");
format(string, sizeof(string), "This vehicle is registered to player: %s",BoughtCarsOwnerName[GetPlayerVehicleID(playerid)]);
SendClientMessage(playerid, COLOR_YELLOW, string);
RemovePlayerFromVehicle(playerid);
The scripts up there will return the 1 character from the string, but how the **** should i get the usernames stored in a string instead of a array?