08.02.2013, 22:31
Hey,
I'm currently learning how to script based off knowledge from other languages, but I just can't seem to get my head around spawning a vehicle from the data stored in an SQL database.
I'm writing up a dealership system for an RP server and have everything working fine, but how to spawn the vehicle...
Define:
enum:
Current basic test command(will be edited, this is just to test if the vehicle spawns):
case:
I'm currently learning how to script based off knowledge from other languages, but I just can't seem to get my head around spawning a vehicle from the data stored in an SQL database.
I'm writing up a dealership system for an RP server and have everything working fine, but how to spawn the vehicle...
Define:
Код:
#define THREAD_INITIATE_PVEHICLES
Код:
enum pvinfoE {
pvId,
pvModel,
pvOwnerId,
Float: pvVPosition[3],
Float: pvVRotation,
pvColour[2],
pvSpawned,
pvScriptID,
}
Код:
new pvVariables[MAX_VEHICLES][pvinfoE];
Код:
CMD:vspawn(playerid, params[]) {
if(playerVariables[playerid][pAdminLevel] >= 1) {
CreateVehicle(pvVariables[playerid][pvModel], pvVariables[playerid][pvVPosition][0], pvVariables[playerid][pvVPosition][1], pvVariables[playerid][pvVPosition][2], pvVariables[playerid][pvVRotation], pvVariables[playerid][pvColour][0], pvVariables[playerid][pvColour][1], 1);
}
}
Код:
case THREAD_INITIATE_PVEHICLES: {
mysql_store_result();
new
x,
bool: success = true;
while(mysql_retrieve_row()) {
mysql_get_field("pvId", result);
x = strval(result);
if(systemVariables[vehicleCounts][0] + systemVariables[vehicleCounts][1] + systemVariables[vehicleCounts][2] < MAX_VEHICLES) {
mysql_get_field("pvModel", result);
pvVariables[x][pvModel] = strval(result);
mysql_get_field("pvOwnerId", result);
pvVariables[x][pvOwnerId] = strval(result);
mysql_get_field("pvPosX", result);
pvVariables[x][pvVPosition][0] = floatstr(result);
mysql_get_field("pvPosY", result);
pvVariables[x][pvVPosition][1] = floatstr(result);
mysql_get_field("pvPosZ", result);
pvVariables[x][pvVPosition][2] = floatstr(result);
mysql_get_field("pvPosZAngle", result);
pvVariables[x][pvVRotation] = floatstr(result);
mysql_get_field("pvColour1", result);
pvVariables[x][pvColour][0] = strval(result);
mysql_get_field("pvColour2", result);
pvVariables[x][pvColour][1] = strval(result);
}
}
}


