Hello - 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: Hello (
/showthread.php?tid=622606)
Hello -
Connor Smith - 24.11.2016
I want to make when someone is enter in some vehicle with owner, or maybe faction and IDK to make showing name of faction like this OWNER: FBI, OWNER: Connor_Smith, my script is on MYSQL.
sorry for my bad english
Re: Hello -
Connor Smith - 25.11.2016
Anyone please?
Re: Hello -
mongi - 25.11.2016
i can't help in MySql db but i think no1 can help without knowing the way that ur script work with. (to check if the vehicle owned by a faction or a player)
Re: Hello -
Connor Smith - 25.11.2016
to check if the vehicle owned by a player and faction too
Re: Hello -
Alvitr - 25.11.2016
first you need a value(data) of veh owner/faction for save/load
PHP код:
new CarOwner[MAX_VEHICLES][MAX_PLAYER_NAME], Bool:CarOwned[MAX_VEHICLES], VehType[MAX_VEHICLES], PlayerFaction[MAX_PLAYERS];//it just example, you can use in enumerations or something you want
public OnGameModeInit()
{
LoadCars();
return 1;
}
static LoadCars()
{
...mysql query etc..
cache_get_value_name_int(idx, "faction", VehType[vehicleid]); // load veh faction
cache_get_value_name_null(idx, "owned", CarOwned[vehicleid]); //load owner
cache_get_value_name(idx, "owner", CarOwner[vehicleid]); //load owner
...
}
static SaveCars()
{
...mysql query to save/update car value with faction&owner etc..
}
also load player data PlayerFaction when player login,
and you can check when player entered in veh
PHP код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(CarOwned[vehicleid])
{
static string[64];
format(string, sizeof(string), "This car owner is : %s", CarOwner[vehicleid]);
SendClientMessage(playerid, -1, string);
}
if(VehType[vehicleid] != PlayerFaction[playerid])
{
static string[64], factname[32];
switch(VehType[vehicleid]){
case 1:{
format(factname, sizeof(factname), "FBI");
}
default:{
format(factname, sizeof(factname), "NONE");
}
}
format(string, sizeof(string), "This car is Faction: %s", factname);
SendClientMessage(playerid, -1, string);
}
}
return 1;
}
this just a example,
you can make more good and great by youself!
Re: Hello -
Connor Smith - 25.11.2016
Thanks
I will try to do it, if I need more help, Im gonna write here
)
Re: Hello -
Connor Smith - 26.11.2016
I need help again
Код:
Car_GetCount(playerid)
{
new
count = 0;
for (new i = 0; i != MAX_DYNAMIC_CARS; i ++)
{
if (CarData[i][carExists] && CarData[i][carOwner] == PlayerData[playerid][pCharacter])
{
count++;
}
}
return count;
}
Car_IsOwner(playerid, carid)
{
if (!PlayerData[playerid][pLogged] || PlayerData[playerid][pID] == -1)
return 0;
if ((CarData[carid][carExists] && CarData[carid][carOwner] != 0) && CarData[carid][carOwner] == PlayerData[playerid][pCharacter])
return 1;
return 0;
}
Car_Create(playerid)
CarData[i][carOwner] = owner;
Car_Delete
CarData[carid][carOwner] = 0;
Car_Save
carOwner` = '%s'
And its showing this in mysql table http://prntscr.com/dby2rc
Re: Hello -
Connor Smith - 26.11.2016
Anyone help?
Re: Hello -
Connor Smith - 27.11.2016
Hello?
Re: Hello -
Alvitr - 27.11.2016
do you mean that thing in picture is showing at mysql car owner field?