Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
- ////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////EINSTELLUNGEN////////////////////////////////////////
- #define MAX_TAXIS 5 // Anzahl der Taxis
- #define TAXI_ID 420 // Fahrzeug Typ
- #define PAY_TIME 5 // Abstand in dem Geld abgezogen wird (Sekunden)
- #define TAXI_SKIN 0 // Welcher Skin ist Taxifahrer (0: CJ-Standart Skin)
- new script_taxi[MAX_TAXIS];
- stock CreateTaxis() // Taxis erstellen, MAX_TAXIS muss mit der Anzahl der CreateVehicle übereinstimmen
- {
- script_taxi[0]=CreateVehicle(TAXI_ID,2040.6560,1348.6108,10.6719,132.2145,-1,-1,-1);
- script_taxi[1]=CreateVehicle(TAXI_ID,2040.2594,1341.1702,10.6719,135.3479,-1,-1,-1);
- script_taxi[2]=CreateVehicle(TAXI_ID,2040.5894,1332.7135,10.6719,134.4079,-1,-1,-1);
- script_taxi[3]=CreateVehicle(TAXI_ID,2040.9341,1325.4912,10.6719,136.6012,-1,-1,-1);
- script_taxi[4]=CreateVehicle(TAXI_ID,2040.6262,1316.5095,10.6719,131.9012,-1,-1,-1);
- return 1;
- }
- /******Made by GPawn-Growen******/
- /******Kosten: 5 EUR*************/
- /******Datum: 27.05.2012*********/
- ////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
- #define color_info 0xFFFFFFFF
- #define color_rot 0xAA3333AA
- #define color_gruen 0x33AA33AA
- new player_preis[MAX_PLAYERS];
- new player_taxi[MAX_PLAYERS];
- new pay_taxi[MAX_PLAYERS];
- new payed[MAX_PLAYERS];
- forward check_taxi(playerid,fahrerid,kosten);
- public OnFilterScriptInit()
- {
- CreateTaxis();
- return 1;
- }
- public OnFilterScriptExit()
- {
- for(new v=0;v<MAX_TAXIS;v++)
- {
- DestroyVehicle(script_taxi[v]);
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- payed[playerid]=0;
- player_preis[playerid]=0;
- player_taxi[playerid]=0;
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- dcmd(fahre,5,cmdtext);
- return 0;
- }
- dcmd_fahre(playerid,params[])
- {
- if(GetPlayerSkin(playerid) != TAXI_SKIN) return SendClientMessage(playerid, color_info, "FEHLER: Du bist kein Taxifahrer!");
- new preis,say[80];
- if(sscanf(params, "d",preis)) return SendClientMessage(playerid, color_info,"BENUTZE: /fahre [PREIS]");
- else if(preis > 200 || preis < 1) return SendClientMessage(playerid, color_info, "FEHLER: Preis muss zwischen 1 und 200 EUR liegen!");
- else if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, color_info, "FEHLER: Du darfst nicht in einem Fahrzeug sitzen!");
- player_preis[playerid]=preis;
- format(say,sizeof say,"TAXI: %s ist mit dem Taxi unterwegs, Kosten pro KM: %d",NAME(playerid),player_preis[playerid]);
- SendClientMessageToAll(color_gruen,say);
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- if(newstate == PLAYER_STATE_DRIVER && GetPlayerSkin(playerid) == TAXI_SKIN)
- {
- new xx = GetVehicleModel(GetPlayerVehicleID(playerid));
- if(xx == TAXI_ID)
- {
- player_taxi[playerid]=GetPlayerVehicleID(playerid);
- }
- }
- else if(newstate == PLAYER_STATE_PASSENGER)
- {
- new xx = GetVehicleModel(GetPlayerVehicleID(playerid));
- if(xx == TAXI_ID)
- {
- for(new i=0;i<MAX_PLAYERS;i++)
- {
- if(i != playerid)
- {
- if(GetPlayerVehicleID(playerid) == player_taxi[i])
- {
- return pay_taxi[playerid]=SetTimerEx("check_taxi",PAY_TIME*1000,1,"ddd",playerid,i,player_preis[i]);
- }
- }
- }
- }
- }
- if(oldstate == PLAYER_STATE_PASSENGER || oldstate == PLAYER_STATE_DRIVER )
- {
- player_taxi[playerid]=0;
- payed[playerid]=0;
- return KillTimer(pay_taxi[playerid]);
- }
- return 1;
- }
- public check_taxi(playerid,fahrerid,kosten)
- {
- new say[50];
- payed[playerid]+=kosten;
- format(say,sizeof say,"~r~Kosten: ~w~%d EUR",payed[playerid]);
- GameTextForPlayer(playerid, say, PAY_TIME*1010, 4);
- format(say,sizeof say,"~g~Gehalt: ~w~%d EUR",payed[playerid]);
- GameTextForPlayer(fahrerid, say, PAY_TIME*1010, 4);
- GivePlayerMoney(playerid,-kosten);
- GivePlayerMoney(fahrerid,kosten);
- return 1;
- }
- stock NAME(playerid)
- {
- new spname[128];
- GetPlayerName(playerid,spname,sizeof(spname));
- return spname;
- }
- stock sscanf(string[], format[], {Float,_}:...)
- {
- #if defined isnull
- if (isnull(string))
- #else
- if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
- #endif
- {
- return format[0];
- }
- #pragma tabsize 4
- new
- formatPos = 0,
- stringPos = 0,
- paramPos = 2,
- paramCount = numargs(),
- delim = ' ';
- while (string[stringPos] && string[stringPos] <= ' ')
- {
- stringPos++;
- }
- while (paramPos < paramCount && string[stringPos])
- {
- switch (format[formatPos++])
- {
- case '\0':
- {
- return 0;
- }
- case 'i', 'd':
- {
- new
- neg = 1,
- num = 0,
- ch = string[stringPos];
- if (ch == '-')
- {
- neg = -1;
- ch = string[++stringPos];
- }
- do
- {
- stringPos++;
- if ('0' <= ch <= '9')
- {
- num = (num * 10) + (ch - '0');
- }
- else
- {
- return -1;
- }
- }
- while ((ch = string[stringPos]) > ' ' && ch != delim);
- setarg(paramPos, 0, num * neg);
- }
- case 'h', 'x':
- {
- new
- num = 0,
- ch = string[stringPos];
- do
- {
- stringPos++;
- switch (ch)
- {
- case 'x', 'X':
- {
- num = 0;
- continue;
- }
- case '0' .. '9':
- {
- num = (num << 4) | (ch - '0');
- }
- case 'a' .. 'f':
- {
- num = (num << 4) | (ch - ('a' - 10));
- }
- case 'A' .. 'F':
- {
- num = (num << 4) | (ch - ('A' - 10));
- }
- default:
- {
- return -1;
- }
- }
- }
- while ((ch = string[stringPos]) > ' ' && ch != delim);
- setarg(paramPos, 0, num);
- }
- case 'c':
- {
- setarg(paramPos, 0, string[stringPos++]);
- }
- case 'f':
- {
- new changestr[16], changepos = 0, strpos = stringPos;
- while(changepos < 16 && string[strpos] && string[strpos] != delim)
- {
- changestr[changepos++] = string[strpos++];
- }
- changestr[changepos] = '\0';
- setarg(paramPos,0,_:floatstr(changestr));
- }
- case 'p':
- {
- delim = format[formatPos++];
- continue;
- }
- case '\'':
- {
- new
- end = formatPos - 1,
- ch;
- while ((ch = format[++end]) && ch != '\'') {}
- if (!ch)
- {
- return -1;
- }
- format[end] = '\0';
- if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
- {
- if (format[end + 1])
- {
- return -1;
- }
- return 0;
- }
- format[end] = '\'';
- stringPos = ch + (end - formatPos);
- formatPos = end + 1;
- }
- case 'u':
- {
- new
- end = stringPos - 1,
- id = 0,
- bool:num = true,
- ch;
- while ((ch = string[++end]) && ch != delim)
- {
- if (num)
- {
- if ('0' <= ch <= '9')
- {
- id = (id * 10) + (ch - '0');
- }
- else
- {
- num = false;
- }
- }
- }
- if (num && IsPlayerConnected(id))
- {
- setarg(paramPos, 0, id);
- }
- else
- {
- #if !defined foreach
- #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
- #define __SSCANF_FOREACH__
- #endif
- string[end] = '\0';
- num = false;
- new
- name[MAX_PLAYER_NAME];
- id = end - stringPos;
- foreach (Player, playerid)
- {
- GetPlayerName(playerid, name, sizeof (name));
- if (!strcmp(name, string[stringPos], true, id))
- {
- setarg(paramPos, 0, playerid);
- num = true;
- break;
- }
- }
- if (!num)
- {
- setarg(paramPos, 0, INVALID_PLAYER_ID);
- }
- string[end] = ch;
- #if defined __SSCANF_FOREACH__
- #undef foreach
- #undef __SSCANF_FOREACH__
- #endif
- }
- stringPos = end;
- }
- case 's', 'z':
- {
- new
- i = 0,
- ch;
- if (format[formatPos])
- {
- while ((ch = string[stringPos++]) && ch != delim)
- {
- setarg(paramPos, i++, ch);
- }
- if (!i)
- {
- return -1;
- }
- }
- else
- {
- while ((ch = string[stringPos++]))
- {
- setarg(paramPos, i++, ch);
- }
- }
- stringPos--;
- setarg(paramPos, i, '\0');
- }
- default:
- {
- continue;
- }
- }
- while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
- {
- stringPos++;
- }
- while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
- {
- stringPos++;
- }
- paramPos++;
- }
- do
- {
- if ((delim = format[formatPos++]) > ' ')
- {
- if (delim == '\'')
- {
- while ((delim = format[formatPos++]) && delim != '\'') {}
- }
- else if (delim != 'z')
- {
- return delim;
- }
- }
- }
- while (delim > ' ');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment