Car Spawner & IP problem
#1

i tried to create a car spawner. ended up in this.but it doesnt seem to work.
please correct me.

pawn Код:
CMD:v(playerid, params[])
    {
        new /*col1, col2,*/ vehid;
        new Float:x,Float:y,Float:z,Float:a;
        GetPlayerPos(playerid, x, y, z);
        GetPlayerFacingAngle(playerid, a);
        if(sscanf(params, "u",vehid)) return SendClientMessage(playerid, -1, "Usage: /v [modelid]");
            ID = GetPlayerVehicleID(playerid);
        ID = CreateVehicle(vehid, x + 2, y, z, a + 90, -1, -1, 10);
        PutPlayerInVehicle(playerid, ID, 0);
        return 1;
     }
i think something is wrong in the ssancf line? hmm

p.s. ID is a global var


and this IP doesnt work properly

pawn Код:
PlayerInfo[playerid][pIP] = GetPlayerIp(playerid, PlayerInfo[playerid][pIP], 16);
    GetPlayerName(playerid, pname, sizeof(pname));

    format(str, sizeof(str), "%s(%d) has joined the server. Ip: %s", pname, playerid, PlayerInfo[playerid][pIP]);
Reply
#2

Car spawner:
pawn Код:
CMD:v(playerid, params[])
{
    new /*col1, col2,*/ vehid;
    new Float:x, Float:y, Float:z, Float:a;
    GetPlayerPos(playerid, x, y, z);
    GetPlayerFacingAngle(playerid, a);
    if(sscanf(params, "i", vehid)) return SendClientMessage(playerid, -1, "Usage: /v [modelid]"); // I prefer using "i" instead of "u" when you want to get vehicle ID, "u" if for players
    // ID = GetPlayerVehicleID(playerid); // you don't need this line, why do you want to get player's vehicle ID if he doesn't have a vehicle
    ID = CreateVehicle(vehid, x + 2.0, y, z, a + 90.0, -1, -1, 10);
    PutPlayerInVehicle(playerid, ID, 0);
    return 1;
}
IP:
pawn Код:
GetPlayerIp(playerid, PlayerInfo[playerid][pIP], 16); // the function itself give the value of PlayerInfo[playerid][pIP]
GetPlayerName(playerid, pname, sizeof(pname));
format(str, sizeof(str), "%s(%d) has joined the server. Ip: %s", pname, playerid, PlayerInfo[playerid][pIP]);
Reply
#3

pawn Код:
new
    ID;
   
CMD:v( playerid, params[ ] )
{
    new /*col1, col2,*/ vehid;
    new Float:x, Float:y, Float:z, Float:a;
    GetPlayerPos( playerid, x, y, z );
    GetPlayerFacingAngle( playerid, a );
    if( sscanf( params, "i", vehid ) ) return SendClientMessage( playerid, -1, "Usage: /v [modelid]" );
    // Note: Only integer. Ex: /v 411 (infernus)
    ID = CreateVehicle( vehid, x + 2, y, z, a + 90, -1, -1, 10 );
    PutPlayerInVehicle( playerid, ID, 0 );
    return 1;
}

    new IP[ 16 ];
    GetPlayerIp( playerid, IP, 16 );
    GetPlayerName( playerid, pname, sizeof( pname ) );
    PlayerInfo[ playerid][ pIP ] = IP;
   

    format(str, sizeof(str), "%s(%d) has joined the server. Ip: %s", pname, playerid, PlayerInfo[playerid][pIP]);
Reply
#4

so enums doesnt support ips? hmm

and how can i make the spawner command so that it will even work with the names..
Reply
#5

Enums support IPs (strings).

pawn Код:
enum playerinfo {
      ip[16]
};
Reply
#6

Yes, enums do support IP address, as they're just stored as string. You were just using GetPlayerIP in a wrong way; the function itself doesn't return anything and the retrieved IP is implicitly stored in the variable.

As for the vehicle names: take a look at sscanf's new 'k' specifier.
Reply
#7

You can use this array to get the vehicle model from their name:
pawn Код:
new VehicleNames[][]= {
    {"Landstalker"}, {"Bravura"}, {"Buffalo"}, {"Linerunner"}, {"Perrenial"},
    {"Sentinel"}, {"Dumper"}, {"Firetruck"}, {"Trashmaster"}, {"Stretch"},
    {"Manana"}, {"Infernus"}, {"Voodoo"}, {"Pony"}, {"Mule"}, {"Cheetah"},
    {"Ambulance"}, {"Leviathan"}, {"Moonbeam"}, {"Esperanto"}, {"Taxi"},
    {"Washington"}, {"Bobcat"}, {"Mr Whoopee"}, {"BF Injection"}, {"Hunter"},
    {"Premier"}, {"Enforcer"}, {"Securicar"}, {"Banshee"}, {"Predator"},
    {"Bus"}, {"Rhino"}, {"Barracks"}, {"Hotknife"}, {"Trailer 1"}, {"Previon"},
    {"Coach"}, {"Cabbie"}, {"Stallion"}, {"Rumpo"}, {"RC Bandit"}, {"Romero"},
    {"Packer"}, {"Monster"}, {"Admiral"}, {"Squalo"}, {"Sparrow"},
    {"Pizzaboy"}, {"Tram"}, {"Trailer 2"}, {"Turismo"}, {"Speeder"}, {"Reefer"},
    {"Tropic"}, {"Flatbed"}, {"Yankee"}, {"Caddy"}, {"Solair"},
    {"Berkley's RC Van"}, {"Skimmer"}, {"PCJ-600"}, {"Faggio"}, {"Freeway"},
    {"RC Baron"}, {"RC Raider"}, {"Glendale"}, {"Oceanic"}, {"Sanchez"},
    {"Seasparrow"}, {"Patriot"}, {"Quad"}, {"Coastguard"}, {"Dinghy"}, {"Hermes"},
    {"Sabre"}, {"Rustler"}, {"ZR-350"}, {"Walton"}, {"Regina"}, {"Comet"},
    {"BMX"}, {"Burrito"}, {"Camper"}, {"Marquis"}, {"Baggage"}, {"Dozer"},
    {"Maverick"}, {"News Maverick"}, {"Rancher"}, {"FBI Rancher"}, {"Virgo"},
    {"Greenwood"}, {"Jetmax"}, {"Hotring"}, {"Sandking"}, {"Blista Compact"},
    {"Police Maverick"}, {"Boxville"}, {"Benson"}, {"Mesa"},{"RC Goblin"},
    {"Hotring Racer A"}, {"Hotring Racer B"}, {"Bloodring Banger"}, {"Rancher"},
    {"Super GT"}, {"Elegant"}, {"Journey"}, {"Bike"}, {"Mountain Bike"},
    {"Beagle"}, {"Cropdust"}, {"Stunt"}, {"Tanker"}, {"Roadtrain"}, {"Nebula"},
    {"Majestic"}, {"Buccaneer"}, {"Shamal"}, {"Hydra"}, {"FCR-900"},
    {"NRG-500"}, {"HPV1000"}, {"Cement Truck"}, {"Tow Truck"}, {"Fortune"},
    {"Cadrona"}, {"FBI Truck"}, {"Willard"}, {"Forklift"}, {"Tractor"},
    {"Combine"}, {"Feltzer"}, {"Remington"}, {"Slamvan"}, {"Blade"},
    {"Freight"}, {"Brownstreak"}, {"Vortex"},{"Vincent"}, {"Bullet"}, {"Clover"},
    {"Sadler"}, {"Ladder Firetruck"}, {"Hustler"}, {"Intruder"}, {"Primo"},
    {"Cargobob"}, {"Tampa"}, {"Sunrise"}, {"Merit"}, {"Utility"}, {"Nevada"},
    {"Yosemite"}, {"Windsor"}, {"Monster A"}, {"Monster B"}, {"Uranus"},
    {"Jester"}, {"Sultan"}, {"Stratum"}, {"Elegy"}, {"Raindance"}, {"RC Tiger"},
    {"Flash"}, {"Tahoma"}, {"Savanna"}, {"Bandito"}, {"Freight Flat"},
    {"Streak Carriage"}, {"Kart"}, {"Mower"}, {"Dune"}, {"Sweeper"},
    {"Broadway"}, {"Tornado"}, {"AT-400"}, {"DFT-30"}, {"Huntley"},
    {"Stafford"}, {"BF-400"}, {"Newsvan"}, {"Tug"}, {"Trailer 3"}, {"Emperor"},
    {"Wayfarer"}, {"Euros"}, {"Hotdog"}, {"Club"}, {"Freight Carriage"},
    {"Trailer 4"},  {"Andromada"}, {"Dodo"}, {"RC Cam"}, {"Launch"},
    {"Police Car (LSPD)"}, {"Police Car (SFPD)"}, {"Police Car (LVPD)"},
    {"Police Ranger"}, {"Picador"}, {"S.W.A.T. Van"}, {"Alpha"}, {"Phoenix"},
    {"Old Glendale"}, {"Old Sadler"}, {"Luggage Trailer A"}, {"Luggage Trailer B"},
    {"Stair Trailer"}, {"Boxville"}, {"Farm Plow"}, {"Utility Trailer"};
pawn Код:
new i, model;

for (i = 0; i < sizeof(VehicleNames); i++) {
    if (strcmp(VehicleNames[i], "the vehicle's name", false) == 0) break;// if the names are the same
}

model = i + 400;// because vehicle models are from 400
EDIT:
Quote:
Originally Posted by Vince
Посмотреть сообщение
As for the vehicle names: take a look at sscanf's new 'k' specifier.
You're right, this way is easier.
Reply
#8

ohk.

and what do i do if i want to make these ids just for admins? this is not working.
pawn Код:
if(vehid == 520 || vehid == 425 || vehid == 432 || vehid == 430 && PlayerInfo[playerid][pAdmin] <=2) return SendClientMessage(playerid, red, "You cannot spawn this vehicle");

        vid = CreateVehicle(vehid, x + 2, y, z, a + 90, col1, col2, 0);
        LinkVehicleToInterior(vid, GetPlayerInterior(playerid));
        SetVehicleVirtualWorld(vid, GetPlayerVirtualWorld(playerid));
        PutPlayerInVehicle(playerid, vid, 0);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)