How to remove o kill a player when he enter on "Rhino"
#1

Hey there! I'm beginning to script a freeroam gamemode. I've already created the command to spawn vehicles with "/v name vehicle"... in the list of vehicles there is too the "Rhino". Then, I've tryed to remove the "Rhino" from the list, but in the game if I try to spawn for example an "Hydra", the script spawn me a "Shamal". On the contrary if keep the "Rhino" on the list, the Hydra spawn succesfully. The Hydra is just an example.. The problem is with all the vehicles ... For this reason I was forced to put again the Rhino in the list... Anyway, how i can remove-kill a player from the "Rhino" when he enter on it?
Reply
#2

Well, your problem lies somewhere else. Shamal has an id = 519, while hydra has id = 520. If someone wants to spawn 520, he gets 519. What if someone will try to spawn id 400? You have somewhere off by one error.
Reply
#3

Post the code of ShowPlayerDialog for those vehicles and OnPlayerDialog part or the whole OnPlayerDialog here, I will FIX it for you instead of using your approach. Removing Rhino could be less fun for your script. Hehe.
Reply
#4

I give you my gamemode. Thanks for the help. P.S the gamemode is half Italian, I hope you understand something! NOTE PLEASE: The command that don't work is /v, and not /vehicles. Pretend that /vehicles does not exist in the script!
DOWNLOAD LINK: http://www.solidfiles.com/d/6468aa99b5/
Reply
#5

Refer to post below me. He beat me to it. :P
Reply
#6

Your problem is simple. Removing Rhino from the list, all IDs larger than Rhino's will move down by one. in order to prevent that from happening you have to add filter on Vehicle.

pawn Код:
if(car == 432) return SendClientMessage(playerid,0xFF0000FF,"You can't spawn Rhino!"); //rhino
That goes in your command after you check is number higher than 611 or lower than 400.

Complete code is:
pawn Код:
if(strcmp(cmd, "/v", true)==0)
    {
        tmp = strtok2(cmdtext, idx);
        if(!strlen(tmp) || strlen(tmp) > 32) { return SendClientMessage(playerid, ARANCIONE, "USE{FFFFFF}: {F2FF00}/v (namecar)"); }
        new car;
        if(!IsNumeric(tmp)) { car = GetVehicleModelIDFromName(tmp); } else { car = strval(tmp); }
        if(car > 611 || car < 400) { return SendClientMessage(playerid, ARANCIONE, "{FF0000}ID {FFFFFF}or {FF0000}Name Vehicle {FFFFFF}Invalid"); }
        if(car == 432) return SendClientMessage(playerid,0xFF0000FF,"You can't spawn Rhino!"); //rhino
        if(CreaVeicolo[playerid] != -1) { DestroyVehicle(CreaVeicolo[playerid]); }
        new Float:pos[4];
        GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
        GetPlayerFacingAngle(playerid, pos[3]);
        CreaVeicolo[playerid] = CreateVehicle(car, pos[0], pos[1], pos[2], pos[3], -1, -1, 50000);
        PutPlayerInVehicle(playerid, CreaVeicolo[playerid], 0);
        new MaxPlayers = GetMaxPlayers();
        for(new i; i < MaxPlayers; i++)
        {
            if(!IsPlayerConnected(i) || i == playerid) continue;
            SetVehicleParamsForPlayer(CreaVeicolo[playerid], i, 0, true);
        }
        new string[144];
        format(string, sizeof string, "{FFFFFF}[SISTEMA]: {0099FF}Vehicle: {FF9900}%s. {FFFFFF}Status: {5CD822}Spawned!", NomiVeicoli[car-400]);
        SendClientMessage(playerid, BLU, string);
        return 1;
    }
Reply
#7

Thanks thanks thanks and again thanks! +rep man!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)