30.08.2014, 16:50
Guys i have made a taxi system for my script with /taxi you can call taxi and taxi driver will use /acceptfare to accept offer of fare from taxi driver and it will save that playerid to player file of id but i got a problem with fayfare command with this you can pay fare to taxi driver so i called it id with dini here is the command but problem is when i use /payfare it always giving cash to id 0 player
for accept offer of fare
pawn Код:
if (strcmp(string, "/payfare", true) == 0)
{
new playerName[MAX_PLAYER_NAME],newstring[100],newstring1[120],giveName[MAX_PLAYER_NAME];
new id;
if(TaxiDriverOnDuty[playerid] == 1) return SendClientMessage2(playerid, COLOR_RED, "You are a taxi driver.");
if(CallingTaxi[playerid] == 0) return SendClientMessage(playerid,COLOR_RED,"You are not requesting a taxi.");
GetPlayerName(playerid,playerName,sizeof(playerName));
GetPlayerName(id,giveName,sizeof(giveName));
id = dini_Int(AddDirFile(dir_userfiles, playerName), "FareFor");
if(dini_Int(AddDirFile(dir_userfiles, playerName), "FareFor") == -1) return SendClientMessage2(playerid, COLOR_RED, "You did not accept any fare offer.");
format(newstring, sizeof(newstring), "You have paid $%d fare to %s.", dini_Int(AddDirFile(dir_userfiles, playerName), "Fare"), giveName);
SendClientMessage(playerid,COLOR_ORANGE,newstring);
format(newstring1, sizeof(newstring1), "%s has paid $%d fare to you.", playerName,dini_Int(AddDirFile(dir_userfiles, playerName), "Fare"));
SendClientMessage(giveplayerid,COLOR_RED,newstring1);
GivePlayerMoney(playerid, -dini_Int(AddDirFile(dir_userfiles, playerName), "Fare"));
GivePlayerMoney(id, dini_Int(AddDirFile(dir_userfiles, playerName), "Fare"));
dini_IntSet(AddDirFile(dir_userfiles, playerName), "FareFor", -1);
dini_IntSet(AddDirFile(dir_userfiles, playerName), "Fare", 0);
Offerby[playerid] = 0;
CallingTaxi[playerid] = 0;
return 1;
}
pawn Код:
if (strcmp(string, "/acceptfare", true) == 0)
{
new playerName[MAX_PLAYER_NAME],newstring[100],givedplayerid,newstring1[120],giveName[MAX_PLAYER_NAME],newstring3[100];
if(CallingTaxi[playerid] == 0) return SendClientMessage(playerid,COLOR_RED,"You are not requesting a taxi.");
tmp = strtok(cmdtext, idx);
if (!strlen(tmp)) return SendClientMessage2(playerid, COLOR_WHITE, "Usage: /acceptfare [playerid]");
givedplayerid = strval(tmp);
GetPlayerName(playerid,playerName,sizeof(playerName));
GetPlayerName(givedplayerid,giveName,sizeof(giveName));
format(newstring3, sizeof(newstring3), "%s did not offered you the taxi fare.", giveName);
if (!IsPlayerConnected2(givedplayerid) || !isNumeric(tmp)) return SendClientMessage2(playerid, COLOR_RED, "Error: Inactive player id!");
if (orcl[givedplayerid][0] != 0) return SendPlayerFormattedText(playerid, COLOR_WHITE, "Please wait until %s has spawned.", giveName, "");
if(givedplayerid == playerid) return SendClientMessage2(playerid, COLOR_RED, "You are a taxi driver.");
if(Offerby[playerid] == 0) return SendClientMessage2(playerid, COLOR_RED, newstring3);
if(dini_Int(AddDirFile(dir_userfiles, playerName), "FareFor") != -1) return SendClientMessage2(playerid, COLOR_RED, "You already accept somone's offer decline or cancel your request before accept another fare.");
format(newstring, sizeof(newstring), "You have accepted %s offered with a fare of $%d.", giveName,dini_Int(AddDirFile(dir_userfiles, playerName), "Fare"));
SendClientMessage(playerid,COLOR_ORANGE,newstring);
format(newstring1, sizeof(newstring1), "%s has accepted your fare of $%d for a taxi.", giveName,dini_Int(AddDirFile(dir_userfiles, playerName), "Fare"));
SendClientMessage(givedplayerid,COLOR_ORANGE,newstring1);
dini_IntSet(AddDirFile(dir_userfiles, playerName), "FareFor", givedplayerid);
return 1;
}