Re: Vehicle Ownership With Mysql & SScanf -
DiddyBop - 16.11.2010
Good job. Though.. what if there is 1..2..3..4k Cars being reloaded.. Going to cause lag regardless. But minimize it some by changing "for(new i; i < SCRIPT_CARS; i++)" to "foreach(customthing, i)" Not sure if it applies to this. Might remove some lag. Might not.
Other then that. Great job.
Re: Vehicle Ownership With Mysql & SScanf -
Cameltoe - 16.11.2010
Quote:
Originally Posted by iTorran
I did it all and when i go ingame and type /createveh 562 my server closes..
There is no reports on the server log.
|
I'm not sure if thats related to this tutorial, as when i made it, it worked perfectly for me.
Quote:
Originally Posted by DiddyBop
Good job. Though.. what if there is 1..2..3..4k Cars being reloaded.. Going to cause lag regardless. But minimize it some by changing "for(new i; i < SCRIPT_CARS; i++)" to "foreach(customthing, i)" Not sure if it applies to this. Might remove some lag. Might not.
Other then that. Great job.
|
I'm Having about 600 cars loaded from mysql, don't notice lagg at all.. And the max limit for cars is 2k.
Thanks anyway
Re: Vehicle Ownership With Mysql & SScanf -
iTorran - 17.11.2010
Ok ive got it working but ive hit a problem..
I'd normally know how to do this but i just cant think of anything atm.
Anyway i dont know how to restrict a car i created to 1 name.
I tried this:
pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(newstate == PLAYER_STATE_DRIVER)
{
if(strcmp(GetName(playerid), VehicleInfo[vehicleid][Owner], true) == 0)
{
return 1;
}
else
{
RemovePlayerFromVehicle(playerid);
}
}
return 1;
}
But that kicks me out no-matter.
Do anyone know how?
Re: Vehicle Ownership With Mysql & SScanf -
Cameltoe - 17.11.2010
pawn Code:
public OnPlayerEnterVehicle(playerid, vehicleid)
{
if(strmatch(VehicleInfo[vehicleid][Owner], GetName(playerid)))
{
return 1;
}
else
{
// clear animations, cant be bothered searching it up x))
}
return 1;
}
stock strmatch(const String1[], const String2[])
{
if ((strcmp(String1, String2, true, strlen(String2)) == 0) && (strlen(String2) == strlen(String1)))
{
return true;
}
else
{
return false;
}
}
Should work.
Re: Vehicle Ownership With Mysql & SScanf -
iTorran - 18.11.2010
Quote:
Originally Posted by Cameltoe
pawn Code:
public OnPlayerEnterVehicle(playerid, vehicleid) { if(strmatch(VehicleInfo[vehicleid][Owner], GetName(playerid))) { return 1; } else { // clear animations, cant be bothered searching it up x)) } return 1; }
stock strmatch(const String1[], const String2[]) { if ((strcmp(String1, String2, true, strlen(String2)) == 0) && (strlen(String2) == strlen(String1))) { return true; } else { return false; } }
Should work.
|
Getting the same result..
Re: Vehicle Ownership With Mysql & SScanf -
Cameltoe - 18.11.2010
Try printf("%s",VehicleInfo[vehicleid][Owner]) to see if the owner actually gets loaded.
Re: Vehicle Ownership With Mysql & SScanf -
iTorran - 18.11.2010
When i do: /createveh Torran
I edited it btw to save owner not model,
Anyway when i do that i get sscanf warning and it dosent show the print that i told it to.
And when i get in the vehicle where its supposed to print i also get the sscanf error.
And when i /reloadvehicles it shows the vehicle owner name.
Re: Vehicle Ownership With Mysql & SScanf -
Game94 - 27.11.2010
Whats the problem ?
pawn Code:
sscanf(Query, "p<|>e<is[25]iiffffiii>", VehicleInfo[id]); //78
pawn Code:
enum vInfo
{
vId,
vOwner[25],
vModel,
vPrice,
vFloat:X,
vFloat:Y,
vFloat:Z,
vFloat:A,
vColor1,
vColor2,
vLocked,
}
new VehicleInfo[MAX_VEH][vInfo];
pawn Code:
C:\Documents and Settings\XP4ever\Asztal\samp\filterscripts\carsystem.pwn(78) : error 017: undefined symbol "VehicleInfo"
C:\Documents and Settings\XP4ever\Asztal\samp\filterscripts\carsystem.pwn(78) : warning 215: expression has no effect
C:\Documents and Settings\XP4ever\Asztal\samp\filterscripts\carsystem.pwn(78) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\XP4ever\Asztal\samp\filterscripts\carsystem.pwn(78) : error 029: invalid expression, assumed zero
C:\Documents and Settings\XP4ever\Asztal\samp\filterscripts\carsystem.pwn(78) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
4 Errors.
Re: Vehicle Ownership With Mysql & SScanf -
SuperS82 - 29.11.2010
@iTorran try this:
pawn Code:
public OnPlayerStateChange(playerid)
{
new playername[MAX_PLAYERNAME];
GetPlayerName(playerid,playername,sizeof(playername));
new vehicleid = GetPlayerVehicleID(playerid);
if(newstate == PLAYER_STATE_DRIVER)
{
new namestring = strfind(playername,VehicleInfo[vehicleid][Owner],true);
if(namestring == -1)
{
RemovePlayerFromVehicle(playerid);
}
}
return 1;
}
Re: Vehicle Ownership With Mysql & SScanf -
Rokzlive - 06.12.2010
Can someone post an example.pwn cause i cant get it right :/ Im noob to mysql and pwn.
Re: Vehicle Ownership With Mysql & SScanf -
MartinJ1 - 20.04.2012
I had some errors, but it was helpful

hopefully figuring out them soon..