Bom, da pra fazer algo meio dнficil de fazer, como conectar set, desconectar, etc..
Se vocк quiser estudar isso, lembrando que de comeзo й dнficil, Se vocк й novato no Pawn, recomendo primeiro saber como fazer Sistema de Registro, aprender MySQL, etc..
PHP Code:
#include <a_samp>
#include <ZCMD>
#include <sscanf2>
#include <DOF2>
native IsValidVehicle(vehicleid);
#define MAX_PLAYER_CAR 10
enum pCar
{
cVeiculoID,
cModelo,
cCor1,
cCor2,
Float:cX,
Float:cY,
Float:cZ,
Float:cT,
pIDConectado, /* Pelo ID Do Arquivo */
}
new PlayerCar[MAX_PLAYERS][pCar];
CMD:comprarveiculo(playerid, params[])
{
static
modelo, cor1, cor2;
if(sscanf(params, "ddd", modelo, cor1, cor2))
return SendClientMessage(playerid, -1, "* /comprarveiculo [modeloid] [cor1] [cor2]");
if(modelo < 400 || modelo > 611)
return SendClientMessage(playerid, -1, "* Modelo Invбlido de Veнculo.");
if(cor1 < 0 || cor2 > 255)
return SendClientMessage(playerid, -1, "* ID de cor invбlido !");
// -------------------------------------------- //
CriarCarro(playerid, modelo, cor1, cor2);
return 1;
}
CMD:meusveiculos(playerid)
{
new
file[100],
yDialog[150],
rdialog[150],
contar;
for(new i = 1; i != MAX_PLAYER_CAR; ++ i)
{
format(file, sizeof(file), "/Veiculos/Veiculo %s_%d.ini", ReturnName(playerid), i);
if(DOF2_FileExists(file))
{
format(yDialog, sizeof(yDialog), "\t> Set ID: %d | Modelo: %s | Conectado: %s.\n", i, GetVehicleModelName(GetPlayerCarModel(playerid, i)), PlayerCar[playerid][pIDConectado] == i ? ("Conectado") : ("Desconectado"), i);
strcat(rdialog, yDialog);
contar++;
}
}
if(contar != 0) ShowPlayerDialog(playerid, 30000, DIALOG_STYLE_LIST, "Lista de Veнculos...", rdialog, "Selecionar", "Cancelar");
else SendClientMessage(playerid, -1, "* Vocк nгo possui um veнculo !");
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 30000)
{
if(response)
{
for(new i = 1; i < MAX_PLAYER_CAR; ++ i)
{
if(listitem == i - 1)
{
ShowPlayerDialog(playerid, 30001, DIALOG_STYLE_LIST, "Meu Set...", "Conectar\nTrocar Cores\nEstacionar", "Selecionar", "Sair");
}
}
}
}
if(dialogid == 30001) // Aonde vai meche com o set
{
}
return 0;
}
stock GetPlayerSetConectado(playerid) /* Vai retornar o ID Do arquivo */
{
new
file[100];
for(new i = 1; i != MAX_PLAYER_CAR; ++ i)
{
format(file, sizeof(file), "/Veiculos/Veiculo %s_%d.ini", ReturnName(playerid), i);
new
pconectado = DOF2_GetInt(file, "Conectado";
if(pconectado == 1)
{
return i;
}
}
return -1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
new
string[100];
if(PlayerCar[playerid][cVeiculoID] == INVALID_VEHICLE_ID)
{
// Para Carros que nгo й set.
return 1;
}
else if(PlayerCar[playerid][cVeiculoID] == vehicleid)
{
format(string, sizeof(string), "» Bem vindo ao seu Set ----- > ( %s ) .", GetSetModeloName(playerid));
SendClientMessage(playerid, -1, string);
}
else if(PlayerCar[playerid][cVeiculoID] != vehicleid)
{
SendClientMessage(playerid, -1, "Esse set nгo й seu.");
RemovePlayerFromVehicle(playerid);
}
}
return 1;
}
stock GetSetModeloName(playerid) /* Retorna o Set que estб Conectado */
{
new
file[100];
format(file, sizeof(file), "/Veiculos/Veiculo %s_%d.ini", ReturnName(playerid), PlayerCar[playerid][pIDConectado]);
new modelo = DOF2_GetInt(file, "Modelo");
GetVehicleModelName(modelo);
}
stock GetPlayerCarModel(playerid, id) /* Esse ID Seria o do arquivo */
{
new
file[100];
format(file, sizeof(file), "/Veiculos/Veiculo %s_%d.ini", ReturnName(playerid), id);
if(DOF2_FileExists(file))
{
new model = DOF2_GetInt(file, "Modelo");
return model;
}
return -1;
}
stock DesconectarSet(playerid, vehicleid)
{
new
file[100];
for(new i = 1; i != MAX_PLAYER_CAR; ++ i)
{
format(file, sizeof(file), "/Veiculos/Veiculo %s_%d.ini", ReturnName(playerid), i);
DOF2_SetInt(file, "Conectado", 0);
DOF2_SaveFile();
if(IsValidVehicle(vehicleid)) DestroyVehicle(vehicleid);
PlayerCar[playerid][cVeiculoID] = INVALID_VEHICLE_ID;
PlayerCar[playerid][pIDConectado] = 0;
}
return -1;
}
stock CriarCarro(playerid, modelo, cor1, cor2)
{
static
cIDArquivo = -1,
file[50];
for(new i = 1; i != MAX_PLAYER_CAR; ++ i)
{
format(file, sizeof(file), "/Veiculos/Veiculo %s_%d.ini", ReturnName(playerid), i);
if(!DOF2_FileExists(file)) cIDArquivo = i;
else SendClientMessage(playerid, -1, "* Vocк nгo pode ter mais veнculos, vocк jб possui "#MAX_PLAYER_CAR".");
}
if(cIDArquivo != -1)
{
if(PlayerCar[playerid][cVeiculoID] != INVALID_VEHICLE_ID)
{
DesconectarSet(playerid, PlayerCar[playerid][cVeiculoID]);
}
static
Float:yPos[4];
GetPlayerPos(playerid, yPos[0], yPos[1], yPos[2]);
GetPlayerFacingAngle(playerid, yPos[3]);
// ---------------------------- //
static
VeiculoID;
VeiculoID = CreateVehicle(modelo, yPos[0], yPos[1], yPos[2], yPos[3], cor1, cor2, 300, -1);
// ---------------------------- //
PlayerCar[playerid][cVeiculoID] = VeiculoID;
PlayerCar[playerid][cModelo] = modelo;
PlayerCar[playerid][cCor1] = cor1;
PlayerCar[playerid][cCor2] = cor2;
PlayerCar[playerid][cX] = yPos[0];
PlayerCar[playerid][cY] = yPos[1];
PlayerCar[playerid][cZ] = yPos[2];
PlayerCar[playerid][cT] = yPos[3];
PlayerCar[playerid][pIDConectado] = cIDArquivo;
// ---------------------------- //
new
pfile[60];
format(pfile, sizeof(pfile), "/Veiculos/Veiculo %s_%d.ini", ReturnName(playerid), cIDArquivo);
DOF2_CreateFile(pfile);
DOF2_SetInt(pfile, "Modelo", modelo);
DOF2_SetFloat(pfile, "Posiзгo X", yPos[0]);
DOF2_SetFloat(pfile, "Posiзгo Y", yPos[1]);
DOF2_SetFloat(pfile, "Posiзгo Z", yPos[2]);
DOF2_SetFloat(pfile, "Posiзгo T", yPos[3]);
DOF2_SetInt(pfile, "Cor 1", cor1);
DOF2_SetInt(pfile, "Cor 2", cor2);
DOF2_SaveFile();
// ---------------------------- //
new
string[50];
format(string, sizeof(string), "Veнculo Modelo %d | Cor 1: %d | Cor 2: %d Criado !.", modelo, cor1, cor2);
SendClientMessage(playerid, -1, string);
}
return INVALID_VEHICLE_ID;
}
stock ReturnName(playerid)
{
new
pNome[24];
GetPlayerName(playerid, pNome, sizeof(pNome));
return pNome;
}
stock GetVehicleModelName(v)
{
new s[35];
switch((v))
{
case 400:s="Landstalker";
case 401:s="Bravura";
case 402:s="Buffalo";
case 403:s="Linerunner";
case 404:s="Perenail";
case 405:s="Sentinel";
case 406:s="Dumper";
case 407:s="Firetruck";
case 408:s="Trashmaster";
case 409:s="Stretch";
case 410:s="Manana";
case 411:s="Infernus";
case 412:s="Voodoo";
case 413:s="Pony";
case 414:s="Mule";
case 415:s="Cheetah";
case 416:s="Ambulance";
case 417:s="Levetian";
case 418:s="Moonbeam";
case 419:s="Esperanto";
case 420:s="Taxi";
case 421:s="Washington";
case 422:s="Bobcat";
case 423:s="Mr Whoopee";
case 424:s="BF Injection";
case 425:s="Hunter";
case 426:s="Premier";
case 427:s="Enforcer";
case 428:s="Securicar";
case 429:s="Banshee";
case 430:s="Predator";
case 431:s="Bus";
case 432:s="Rhino";
case 433:s="Barracks";
case 434:s="Hotknife";
case 435:s="Artic Trailer 1";
case 436:s="Previon";
case 437:s="Coach";
case 438:s="Cabbie";
case 439:s="Stallion";
case 440:s="Rumpo";
case 441:s="RC Bandit";
case 442:s="Romero";
case 443:s="Packer";
case 444:s="Monster";
case 445:s="Admiral";
case 446:s="Squalo";
case 447:s="Seasparrow";
case 448:s="Pizza Boy";
case 449:s="Tram";
case 450:s="Artic Trailer 2";
case 451:s="Turismo";
case 452:s="Speeder";
case 453:s="Reefer";
case 454:s="Tropic";
case 455:s="Flatbed";
case 456:s="Yankee";
case 457:s="Caddy";
case 458:s="Solair";
case 459:s="Top Fun";
case 460:s="Skimmer";
case 461:s="PCJ-600";
case 462:s="Faggio";
case 463:s="Freeway";
case 464:s="RC Baron";
case 465:s="RC Raider";
case 466:s="Glendale";
case 467:s="Oceanic";
case 468:s="Sanchez";
case 469:s="Sparrow";
case 470:s="Patriot";
case 471:s="Quad";
case 472:s="Coastguard";
case 473:s="Dinghy";
case 474:s="Hermes";
case 475:s="Sabre";
case 476:s="Rustler";
case 477:s="ZR-350";
case 478:s="Walton";
case 479:s="Regina";
case 480:s="Comet";
case 481:s="BMX";
case 482:s="Burrito";
case 483:s="Camper";
case 484:s="Marquis";
case 485:s="Baggage";
case 486:s="Dozer";
case 487:s="Maverick";
case 488:s="SAN Maverick";
case 489:s="Rancher";
case 490:s="FBI Rancher";
case 491:s="Virgo";
case 492:s="Greenwood";
case 493:s="Jetmax";
case 494:s="Hotring";
case 495:s="Sandking";
case 496:s="Blista Compact";
case 497:s="Police Maverick";
case 498:s="Boxvillie";
case 499:s="Benson";
case 500:s="Mesa";
case 501:s="RC Goblin";
case 502:s="Hotring";
case 503:s="Hotring";
case 504:s="Bloodring Banger";
case 505:s="Rancher";
case 506:s="Super GT";
case 507:s="Elegant";
case 508:s="Journey";
case 509:s="Bike";
case 510:s="Mountain Bike";
case 511:s="Beagle";
case 512:s="Cropduster";
case 513:s="Stuntplane";
case 514:s="Petrol";
case 515:s="Roadtrain";
case 516:s="Nebula";
case 517:s="Majestic";
case 518:s="Buccaneer";
case 519:s="Shamal";
case 520:s="Hydra";
case 521:s="FCR-900";
case 522:s="NRG-500";
case 523:s="HPV-1000";
case 524:s="Cement Truck";
case 525:s="Tow Truck";
case 526:s="Fortune";
case 527:s="Cadrona";
case 528:s="FBI Truck";
case 529:s="Williard";
case 530:s="Forklift";
case 531:s="Tractor";
case 532:s="Combine";
case 533:s="Feltzer";
case 534:s="Remington";
case 535:s="Slamvan";
case 536:s="Blade";
case 537:s="Freight";
case 538:s="Streak";
case 539:s="Vortex";
case 540:s="Vincent";
case 541:s="Bullet";
case 542:s="Clover";
case 543:s="Sadler";
case 544:s="Firetruck";
case 545:s="Hustler";
case 546:s="Intruder";
case 547:s="Primo";
case 548:s="Cargobob";
case 549:s="Tampa";
case 550:s="Sunrise";
case 551:s="Merit";
case 552:s="Utility Van";
case 553:s="Nevada";
case 554:s="Yosemite";
case 555:s="Windsor";
case 556:s="Monster";
case 557:s="Monster";
case 558:s="Uranus";
case 559:s="Jester";
case 560:s="Sultan";
case 561:s="Stratum";
case 562:s="Elegy";
case 563:s="Raindance";
case 564:s="RC Tiger";
case 565:s="Flash";
case 566:s="Tahoma";
case 567:s="Savanna";
case 568:s="Bandito";
case 569:s="Freight Flat";
case 570:s="Streak";
case 571:s="Kart";
case 572:s="Mower";
case 573:s="Duneride";
case 574:s="Sweeper";
case 575:s="Broadway";
case 576:s="Tornado";
case 577:s="AT-400";
case 578:s="DFT-30";
case 579:s="Huntley";
case 580:s="Stafford";
case 581:s="BF-400";
case 582:s="News van";
case 583:s="Tug";
case 584:s="Petrol Tanker";
case 585:s="Emperor";
case 586:s="Wayfarer";
case 587:s="Euros";
case 588:s="Hotdog";
case 589:s="Club";
case 590:s="Freight Box";
case 591:s="Artic Trailer";
case 592:s="Andromada";
case 593:s="Dodo";
case 594:s="RC Cam";
case 595:s="Launch";
case 596:s="Cop Car LS";
case 597:s="Cop Car SF";
case 598:s="Cop Car LV";
case 599:s="Ranger";
case 600:s="Picador";
case 601:s="Swat Tank";
case 602:s="Alpha";
case 603:s="Phoenix";
case 604:s="Glendale";
case 605:s="Sadler";
case 606:s="Bag Box";
case 607:s="Bag Box";
case 608:s="Stairs";
case 609:s="Boxville";
case 610:s="Farm Trailer";
case 611:s="Utility Trailer";
}
return s;
}
Posso fazer um cуdigo melhor que esse, se tiver interesse, chame pv no forum.