enum pInfo { pCarID }; new PlayerInfo[MAX_PLAYERS][pInfo]; enum cInfo { ORM:ORM_ID, ID, Owner[MAX_PLAYER_NAME], Locked, Float:Vposx, Float:Vposy, Float:Vposz, Float:Vposa, Model, Color1, Color2, CarID }; new CarInfo[MAX_VEHICLES][cInfo]; new TotalVeh; public OnGameModeInit() { mysql_tquery(g_SQL, "SELECT * FROM `vehicles`", "OnVehiclesLoad", ""); return 1; } public OnPlayerConnect(playerid) { PlayerInfo[playerid][pCarID] = -1; return 1; } public OnPlayerDisconnect(playerid, reason) { PlayerInfo[playerid][pCarID] = -1; return 1; } forward OnVehiclesLoad(); public OnVehiclesLoad() { new time = GetTickCount(); new c; for(c = 0; c < cache_num_rows(); c++) { new ORM:ormid = CarInfo[c][ORM_ID] = orm_create("vehicles"); orm_addvar_int(ormid, CarInfo[c][ID], "ID"); orm_setkey(ormid, "ID"); orm_addvar_string(ormid, CarInfo[c][Owner], MAX_PLAYER_NAME, "Owner"); orm_addvar_int(ormid, CarInfo[c][Locked], "Locked"); orm_addvar_float(ormid, CarInfo[c][Vposx], "Vposx"); orm_addvar_float(ormid, CarInfo[c][Vposy], "Vposy"); orm_addvar_float(ormid, CarInfo[c][Vposz], "Vposz"); orm_addvar_float(ormid, CarInfo[c][Vposa], "Vposa"); orm_addvar_int(ormid, CarInfo[c][Model], "Model"); orm_addvar_int(ormid, CarInfo[c][Color1], "Color1"); orm_addvar_int(ormid, CarInfo[c][Color2], "Color2"); orm_apply_cache(ormid, c); TotalVeh++; CarInfo[c][CarID] = CreateVehicle(CarInfo[c][Model], CarInfo[c][Vposx], CarInfo[c][Vposy], CarInfo[c][Vposz], CarInfo[c][Vposa], CarInfo[c][Color1], CarInfo[c][Color2], -1); } printf("%d personal cars loaded with %d ms",TotalVeh,GetTickCount() - time); return 1; } public OnPlayerStateChange(playerid, newstate, oldstate) { if(newstate == PLAYER_STATE_DRIVER) { for(new v = 1; v <= TotalVeh; v++) { PlayerInfo[playerid][pCarID] = CarInfo[v][ID]; } } return 1; } CMD:carid(playerid, params[]) { SendMes(playerid, 0x131313, "{FFFFFF}%d",PlayerInfo[playerid][pCarID]); return 1; }
Код:
CMD:carid(playerid, params[]) { SendMes(playerid, 0x131313, "{FFFFFF}%s",PlayerInfo[playerid][pCarID]); return 1; } |
Код:
CMD:carid(playerid, params[]) { SendMes(playerid, 0x131313, "{FFFFFF}%s",PlayerInfo[playerid][pCarID]); return 1; } |
public OnPlayerStateChange(playerid, newstate, oldstate)
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
for(new v = 1; v != TotalVeh; v++)
{
PlayerInfo[playerid][pCarID] = v;
}
}
return 1;
}