(HELP)I need add command /dlicense (id) in this script
#1

Quote:

/*
This Filterscript was created by Sgt (Sascha).
It was made for SA-MP.com.
Everyone may use this script, however you may not claim it as your own!
Editing or removing this credit lines is strictly forbidden!
*/
#define FILTERSCRIPT

#include <a_samp>

#define COLOR_RED 0xAC0404AA
#define COLOR_GREEN 0x39CC00AA
#define COLOR_GREY 0x7F7F7FAA

enum PlayerSaves
{
InPickUp,
Step,
Vehicle,
Float:VH,
CP
}

new PlayerData[MAX_PLAYERS][PlayerSaves];
new sgt_vehicle[MAX_VEHICLES];
new sgt_pickup;

new FloatLCP[][3] =
{
{2094.2458,-1757.2183,13.2750},
{2114.8501,-1547.3146,24.4346},
{2093.0437,-1383.5345,23.7028},
{2074.2417,-1222.6780,23.6977},
{2011.9783,-1133.2168,24.8681},
{1967.5641,-1191.1130,25.6288},
{1899.7421,-1259.0839,13.2739},
{1778.6519,-1281.2861,13.3479},
{1712.1005,-1349.0924,13.2579},
{1660.6407,-1437.3768,13.2579},
{1449.2258,-1479.7397,13.2467},
{1426.7952,-1642.2052,13.2524},
{1531.7705,-1734.7625,13.2622},
{1878.1281,-1753.6519,13.2579},
{2062.4692,-1754.5667,13.2658},
{2062.0320,-1918.8903,13.4219}

};

public OnFilterScriptInit()
{
print("\n--------------------------------------");
print("Driving License v0.6 by Sgt aka Sascha");
print("--------------------------------------\n");

sgt_pickup = CreatePickup(1239, 23, 1491.2736,1307.4366,1093.2891, -1);
return 1;
}

public OnFilterScriptExit()
{
print("\n--------------------------------------");
print("Shutting down Sgt's Driving License v0.6");
print("--------------------------------------\n");
return 1;
}

public OnPlayerSpawn(playerid)
{
PlayerData[playerid][InPickUp] = 0;
PlayerData[playerid][Step] = 0;
PlayerData[playerid][CP] = -1;
return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
if(PlayerData[playerid][Step] > 1)
{
SendClientMessage(playerid, COLOR_RED, "You've failed your driving test.");
}
return 1;
}

public OnVehicleSpawn(vehicleid)
{
if(sgt_vehicle[vehicleid] == 1)
{
SetVehicleToRespawn(vehicleid);
}
return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
if(sgt_vehicle[vehicleid] == 1)
{
SetVehicleToRespawn(vehicleid);
}
return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
if(PlayerData[playerid][Step] >= 1)
{
PlayerData[playerid][Vehicle] = GetPlayerVehicleID(playerid);
GetVehicleHealth(GetPlayerVehicleID(playerid), PlayerData[playerid][VH]);
SendClientMessage(playerid, COLOR_GREEN, "Drive to the first checkpoint and follow the following ones");
PlayerData[playerid][Step] = 2;
SetPlayerRaceCheckpoint(playerid, 0, 2083.5579,-1914.2047,13.2578, 2094.2458,-1757.2183,13.2750 , 3.00);
PlayerData[playerid][CP] = 0;
return 1;
}
else if(PlayerData[playerid][Step] == 0)
{
if(!IsDLFree(GetPlayerVehicleID(playerid)))
{
new string[100], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "CarLicenses/%s.ini", pname);
if(!fexist(string))
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED, "You need a driving license to drive the vehicle! ");
}
}
}
}
return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
if(PlayerData[playerid][Step] == 1 && !IsPlayerInAnyVehicle(playerid))
{
new v = CreateVehicle(0,0,0.0,0,0.0,0,0,0);
sgt_vehicle[v] = 1;
SendClientMessage(playerid, COLOR_GREEN, "Get into the vehicle and follow the checkpoints.");
DisablePlayerCheckpoint(playerid);
}
return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
if(IsPlayerInAnyVehicle(playerid) && GetPlayerVehicleID(playerid) == PlayerData[playerid][Vehicle] && PlayerData[playerid][Step] >= 2)
{
if(PlayerData[playerid][CP] <= 14)
{
new n = PlayerData[playerid][CP];
new n2 = PlayerData[playerid][CP] + 1;
SetPlayerRaceCheckpoint(playerid, 0, DLCP[n][0], DLCP[n][1], DLCP[n][2], DLCP[n2][0], DLCP[n2][1], DLCP[n2][2], 2.00);
PlayerData[playerid][CP]++;
}
else if(PlayerData[playerid][CP] == 15)
{
new n = PlayerData[playerid][CP];
SetPlayerRaceCheckpoint(playerid, 1, DLCP[n][0], DLCP[n][1], DLCP[n][2], DLCP[n][0], DLCP[n][1], DLCP[n][2], 2.00);
PlayerData[playerid][CP]++;
}
else
{
DisablePlayerRaceCheckpoint(playerid);
new v = GetPlayerVehicleID(playerid);
new Float:vhp;
GetVehicleHealth(v, vhp);
new Floatif = ((PlayerData[playerid][VH] / 10) - (vhp / 10));
PlayerData[playerid][CP] = -1;
if(Dif <= 2)
{
ShowPlayerDialog(playerid, 138, DIALOG_STYLE_MSGBOX, "Driving License", "Congratulations!\nYou have passed the test and are now\nthe owner of a driving license!", "OK", "");
SetPVarInt(playerid, "CarLicenses", 1);
}
else
{
ShowPlayerDialog(playerid, 138, DIALOG_STYLE_MSGBOX, "Driving License", "We are sorry.\nYou have failed the driving test.\nPlease try it again, later.", "OK", "");
SetPVarInt(playerid, "CarLicenses", 2);
}
}
}
return 1;
}



public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == sgt_pickup)
{
if(PlayerData[playerid][InPickUp] == 0)
{
PlayerData[playerid][InPickUp] = 1;
SetTimerEx("OnPlayerLeavePickUp", 5000, false, "i", playerid);
GameTextForPlayer(playerid, "There you can do driving license test, you need 500 dollars", 5000, 3);
new pname[MAX_PLAYER_NAME], string[100];
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "CarLicenses/%s.ini", pname);
if(GetPlayerMoney(playerid) < 500) return SendClientMessage(playerid, COLOR_RED, "You dont have enough money.");
if(fexist(string)) return SendClientMessage(playerid, COLOR_RED, "You already have a driving license.");
if(GetPlayerMoney(playerid) >= 500)
ShowPlayerDialog(playerid, 137, DIALOG_STYLE_MSGBOX, "Driving License", "Do you wanna Driving License?, \nclick onto 'Start Test' \nit costs 500 dollars", "Start Test", "");
}
}
return 1;
}

forward OnPlayerLeavePickUp(playerid);
public OnPlayerLeavePickUp(playerid)
{
PlayerData[playerid][InPickUp] = 0;
return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 137)
{
if(response)
{
PlayerData[playerid][Step] = 1;
GivePlayerMoney (playerid, -500);
SendClientMessage(playerid, COLOR_GREY, "You paid 500 dollars. Get out of this bulding to start test.");
SetPlayerCheckpoint(playerid, 2046.8928,-1908.0372,13.5469,280.0000);

}
}
else if(dialogid == 13
{
if(GetPVarInt(playerid, "CarLicenses") == 2)
{
SetPVarInt(playerid, "CarLicenses", 0);
PlayerData[playerid][Step] = 0;
RemovePlayerFromVehicle(playerid);
SetVehicleToRespawn(PlayerData[playerid][Vehicle]);
}
else if(GetPVarInt(playerid, "CarLicenses") == 1)
{
new pname[MAX_PLAYER_NAME], string[100];
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "CarLicenses/%s.ini", pname);
new Filegt_file = fopen(string, io_write);
new day, year, month;
getdate(year, month, day);
format(string, sizeof(string), "%s is owning this driving license since: %d/%d/%d\r\n", pname, day, month, year);
fwrite(sgt_file, string);
fclose(sgt_file);
PlayerData[playerid][Step] = 0;
RemovePlayerFromVehicle(playerid);
SetVehicleToRespawn(PlayerData[playerid][Vehicle]);
}
}
return 1;
}

stock IsDLFree(vehicleid)
{
new m = GetVehicleModel(vehicleid);
if(m == 509 || m == 481 || m == 510 || m == 462 || m == 448 || m == 592 || m == 577 || m == 511 || m == 512
|| m == 593 || m == 520 || m == 448 || m == 553 || m == 476 || m == 519 || m == 460 || m == 513 || m == 548
|| m == 425 || m == 417 || m == 487 || m == 488 || m == 497 || m == 469 || m == 563 || m == 447)
{
return 1;
}
return 0;

I need to add command /dlicense (id) what will show to someone if i have license passed, it must look in scriptfiles/Car Licenses folder if there is name.ini like Rupert_Simon.ini. it will be passed if there isnt name it wil be not passed. please could you help me? or script this add?
Reply
#2

nobody knows or nobody wanna help me?
Reply
#3

Please, help me with this, i fu***ing with this already 2 days
Reply
#4

I don't know if that's what you mean, but tell me anyways.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new
        cmd[256], tmp[256], string[128], idx,
        o_name[MAX_LAYER_NAME], p_name[MAX_PLAYER_NAME]
    ;
    cmd = strtok(cmdtext, idx);
    if(strcmp(cmd, "/dlicense", true) == 0)
    {
        tmp = strtok(cmdtext,idx);
        if(!strlen(tmp)) return SendClientMessage(playerid, -1, "USAGE: /dlicense [ID]");
        new id = strval(tmp);
        if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "SERVER: playerid is not connected");
        GetPlayerName(id, o_name, sizeof(o_name));
        GetPlayerName(playerid, p_name, sizeof(p_name));
        format(string, sizeof(string), "CarLicenses/%s.ini", o_name);
        if(!fexist(string)) {
            format(string, sizeof(string), "%s his license, NOT PASSED.", p_name);
            SendClientMessage(id, -1, string);
            format(string, sizeof(string), "You have showed your license to %s.", o_name);
            SendClientMessage(playerid, -1, string);
        } else {
            format(string, sizeof(string), "%s his license, PASSED.", p_name);
            SendClientMessage(id, -1, string);
            format(string, sizeof(string), "You have showed your license to %s.", o_name);
            SendClientMessage(playerid, -1, string);
        }
        printf("LICENSE: [%d]%s showed [%d]%s his license.", playerid, p_name, id, o_name);
        return 1;
    }
    return 0;
}
USE strtok, if you have knowledge with zcmd and sscanf then you better convert it, much better.
pawn Код:
stock strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
Hope that's what you needed..
Reply
#5

Dude, thank you so much, that is what i want, thanks!!!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)