02.12.2012, 08:20
Hello,I have a problem with two filterscripts. When i finish the work don't give me money. Just show this "You win 150,000$" and don't give me the money.How to fix this?
GivePlayerCash(giveplayerid, 150000);
#define FILTERSCRIPT #include <a_samp> #include <sscanf2> #include <YSI/y_ini> #include <YSI\y_commands> #include <streamer> #pragma tabsize 0 #define SCM SendClientMessage #define COLOR_RED 0xD62F4E #define COL_LIGHTBLUE "{1BD3E0}" #define COL_RED "{D62F4E}" #define COL_ORANGE "{E09B1B}" #define COL_WHITE "{FFFFFF}" #define DIALOG_JOB 1093 #define JOB_FILE "Jobs/%d.ini" #define Player_File "Jobs/Player/%s.ini" #define MAX_JOBS 30 #define MAX_CP 30 new bool:False = false, _S_T_R_[128]; #define SendFormatMSG(%0,%1,%2,%3)\ do{\ format(_S_T_R_, sizeof (_S_T_R_), (%2), %3);\ SendClientMessage((%0),(%1), _S_T_R_);\ }\ while (False) #define randomEx(%0,%1) (random((%1) - (%0)) + (%0)) new JobName[MAX_PLAYERS][64], JobCP[MAX_PLAYERS], JobID[MAX_PLAYERS], PlayerCP[MAX_PLAYERS], JobVehID[MAX_PLAYERS], PlayerVeh[MAX_PLAYERS], bool:PlayerWork[MAX_PLAYERS], JobChoose[MAX_PLAYERS], JobMin[MAX_PLAYERS], JobMax[MAX_PLAYERS], bool:PlayerCreateJob[MAX_PLAYERS], bool:JobOnCP[MAX_PLAYERS], Seller[MAX_PLAYERS], Price[MAX_PLAYERS]; enum info { pJob, } new P_Data[MAX_PLAYERS][info]; enum jo { Float:TCPX, Float:TCPY, Float:TCPZ, Name[64], VehID, Choosed, Min, Max, Pickup, Text3D:Label } new Job[MAX_JOBS][jo]; enum jobs { Float:CPX, Float:CPY, Float:CPZ, } new CheckPoint[MAX_JOBS][MAX_CP][jobs]; public OnFilterScriptInit() { for(new i = 1; i<=MAX_JOBS;i++) { new gFile[35],string[128]; format(gFile, 35, JOB_FILE ,i); INI_ParseFile(gFile, "LoadJobs", .bExtra = true, .extra = i); Job[i][Pickup] = CreateDynamicPickup(1239, 23, Job[i][TCPX],Job[i][TCPY],Job[i][TCPZ],-1,-1,-1,100.0); format(string,128,""COL_LIGHTBLUE"To take job "COL_ORANGE"%s\n"COL_LIGHTBLUE"Type "COL_RED"[/takejob]",Job[i][Name]); Job[i][Label] = CreateDynamic3DTextLabel(string, 0xFFFFFF, Job[i][TCPX],Job[i][TCPY],Job[i][TCPZ], 100, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100); } return 1; } public OnFilterScriptExit() { return 1; } public OnGameModeInit() { return 1; } public OnGameModeExit() { return 1; } public OnPlayerRequestClass(playerid, classid) { return 1; } public OnPlayerConnect(playerid) { Seller[playerid] = 999; Price[playerid] = 0; new pFile[48]; format(pFile, 48, Player_File, GetName(playerid)); if(!fexist(pFile)) { new INI:UserFile = INI_Open(pFile); INI_WriteFloat(UserFile, "Job", 0); INI_Close(UserFile); } INI_ParseFile(pFile, "LoadPlayerData", .bExtra = true, .extra = playerid); return 1; } public OnPlayerDisconnect(playerid, reason) { new pFile[48]; format(pFile, 48, Player_File, GetName(playerid)); if(fexist(pFile)) { new INI:UserFile = INI_Open(pFile); INI_WriteInt(UserFile, "Job", P_Data[playerid][pJob]); INI_Close(UserFile); } return 1; } public OnPlayerSpawn(playerid) { return 1; } public OnPlayerDeath(playerid, killerid, reason) { return 1; } public OnPlayerText(playerid, text[]) { return 1; } public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) { return 1; } public OnPlayerExitVehicle(playerid, vehicleid) { return 1; } public OnPlayerStateChange(playerid, newstate, oldstate) { return 1; } public OnPlayerEnterCheckpoint(playerid) { new cpid = PlayerCP[playerid]; new jobid = P_Data[playerid][pJob]; if(cpid >= 1) { if(IsPlayerInRangeOfPoint(playerid,3.0,CheckPoint[jobid][cpid][CPX],CheckPoint[jobid][cpid][CPY],CheckPoint[jobid][cpid][CPZ])) { if(GetPlayerVehicleID(playerid) == PlayerVeh[playerid]) { PlayerCP[playerid]++; cpid = PlayerCP[playerid]; new money = randomEx(Job[jobid][Min],Job[jobid][Max]); if(CheckPoint[jobid][cpid][CPX] == 0.0 && CheckPoint[jobid][cpid][CPY] == 0)//Last Checkpoint { if(Job[jobid][Choosed] == 2) { GivePlayerMoney(playerid,money); SendFormatMSG(playerid,-1,"You are get {E0941B}$%d",money); PlayerCP[playerid] = 0; DestroyVehicle(PlayerVeh[playerid]); SCM(playerid,-1,"You are finish your job!"); DisablePlayerCheckpoint(playerid); PlayerWork[playerid] = false; return 1; } if(Job[jobid][Choosed] == 1){ PlayerCP[playerid] = 2; cpid = PlayerCP[playerid];} } SetPlayerCheckpoint(playerid,CheckPoint[jobid][cpid][CPX],CheckPoint[jobid][cpid][CPY],CheckPoint[jobid][cpid][CPZ],3.0); GivePlayerMoney(playerid,money); SendFormatMSG(playerid,-1,"You are get {E0941B}$%d",money); } } } return 1; } public OnPlayerLeaveCheckpoint(playerid) { return 1; } public OnPlayerPickUpPickup(playerid, pickupid) { return 1; } public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { if(newkeys == KEY_FIRE) { if(PlayerCreateJob[playerid]) { if(JobCP[playerid] == 1) { new dFile[32],Float:Pos[3],string[128]; GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]); format(dFile, 35, JOB_FILE, JobID[playerid]); new INI:File = INI_Open(dFile); INI_WriteString(File, "Name", JobName[playerid]); INI_WriteFloat(File, "TCPX", Pos[0]); INI_WriteFloat(File, "TCPY", Pos[1]); INI_WriteFloat(File, "TCPZ", Pos[2]); INI_WriteInt(File, "Veh", JobVehID[playerid]); INI_WriteInt(File, "Min", JobMin[playerid]); INI_WriteInt(File, "Max", JobMax[playerid]); INI_WriteInt(File, "Choose", JobChoose[playerid]); INI_Close(File); format(Job[JobID[playerid]][Name],64,"%s",JobName[playerid]); Job[JobID[playerid]][TCPX] = Pos[0]; Job[JobID[playerid]][TCPY] = Pos[1]; Job[JobID[playerid]][TCPZ] = Pos[2]; Job[JobID[playerid]][VehID] = JobVehID[playerid]; Job[JobID[playerid]][Choosed] = JobChoose[playerid]; Job[JobID[playerid]][Min] = JobMin[playerid]; Job[JobID[playerid]][Max] = JobMax[playerid]; Job[JobID[playerid]][Pickup] = CreateDynamicPickup(1239, 23, Job[JobID[playerid]][TCPX],Job[JobID[playerid]][TCPY],Job[JobID[playerid]][TCPZ],-1,-1,-1,100.0); format(string,128,""COL_LIGHTBLUE"To take job "COL_ORANGE"%s\n"COL_LIGHTBLUE"Type "COL_RED"[/takejob]",Job[JobID[playerid]][Name]); Job[JobID[playerid]][Label] = CreateDynamic3DTextLabel(string, 0xFFFFFF, Job[JobID[playerid]][TCPX],Job[JobID[playerid]][TCPY],Job[JobID[playerid]][TCPZ], 100, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100); JobCP[playerid]++; } else if(JobCP[playerid] > 1) { new dFile[32],Float:Pos[3],string[6]; GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]); format(dFile, 35, JOB_FILE, JobID[playerid]); new INI:File = INI_Open(dFile); format(string,6,"CPX%d",JobCP[playerid]); INI_WriteFloat(File, string, Pos[0]); CheckPoint[JobID[playerid]][JobCP[playerid]][CPX] = Pos[0]; format(string,6,"CPY%d",JobCP[playerid]); INI_WriteFloat(File, string, Pos[1]); CheckPoint[JobID[playerid]][JobCP[playerid]][CPY] = Pos[1]; format(string,6,"CPZ%d",JobCP[playerid]); INI_WriteFloat(File, string, Pos[2]); CheckPoint[JobID[playerid]][JobCP[playerid]][CPZ] = Pos[2]; INI_Close(File); JobCP[playerid]++; } } } return 1; } public OnPlayerUpdate(playerid) { return 1; } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { switch(dialogid) { case DIALOG_JOB: { if(!response) return 1; switch(listitem) { case 0://Checpoint { SCM(playerid,-1,"You'r choose job based on chekpoint."); ShowPlayerDialog(playerid,DIALOG_JOB+1,DIALOG_STYLE_INPUT,"Job Name","Type job name","Insert","Close"); JobOnCP[playerid] = true; } case 1://Checpoint { SCM(playerid,-1,"You'r choose job based on commands."); ShowPlayerDialog(playerid,DIALOG_JOB+1,DIALOG_STYLE_INPUT,"Job Name","Type job name","Insert","Close"); JobOnCP[playerid] = false; } } } case DIALOG_JOB+1: { if(!response) return 1; if(JobOnCP[playerid]) { JobCP[playerid] = 1; SCM(playerid,-1,"To set checkpoint use click on mouse. First click is location for command /takejob");} format(JobName[playerid],64,"%s",inputtext); ShowPlayerDialog(playerid,DIALOG_JOB+2,DIALOG_STYLE_INPUT,"Job Veh","Type vehicle id for job","Insert","Close"); } case DIALOG_JOB+2: { if(!response) return 1; SendFormatMSG(playerid,-1,"You are choose car id %d",strval(inputtext)); JobVehID[playerid] = strval(inputtext); if(JobOnCP[playerid]) { ShowPlayerDialog(playerid,DIALOG_JOB+3,DIALOG_STYLE_INPUT,"Choose system","1 = After player enter in last\ncheckpoint start again checkpoints\n2 = After player enter in last\ncheckpoint disablecheckpoints\nType 1 or 2","Insert","Close"); } if(!JobOnCP[playerid]) { ShowPlayerDialog(playerid,DIALOG_JOB+6,DIALOG_STYLE_INPUT,"Type command name","Example: sellicecream (with no /)","Insert","Close"); } } case DIALOG_JOB+3: { if(!response) return 1; SendFormatMSG(playerid,-1,"You are choose option %d",strval(inputtext)); JobChoose[playerid] = strval(inputtext); ShowPlayerDialog(playerid,DIALOG_JOB+4,DIALOG_STYLE_INPUT,"Choose minimum","Choose minimum money for get money on checkpoint","Insert","Close"); } case DIALOG_JOB+4: { if(!response) return 1; SendFormatMSG(playerid,-1,"You are choose $%d for minimum money",strval(inputtext)); JobMin[playerid] = strval(inputtext); ShowPlayerDialog(playerid,DIALOG_JOB+5,DIALOG_STYLE_INPUT,"Choose max","Choose max money for get money on checkpoint","Insert","Close"); } case DIALOG_JOB+5: { if(!response) return 1; SendFormatMSG(playerid,-1,"You are choose $%d for max money",strval(inputtext)); JobMax[playerid] = strval(inputtext); } case DIALOG_JOB+6: { if(!response) return 1; new dFile[32],Float:Pos[3],string[200]; GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]); format(dFile, 35, JOB_FILE, JobID[playerid]); new INI:File = INI_Open(dFile); INI_WriteString(File, "Name", JobName[playerid]); INI_WriteFloat(File, "TCPX", Pos[0]); INI_WriteFloat(File, "TCPY", Pos[1]); INI_WriteFloat(File, "TCPZ", Pos[2]); INI_WriteInt(File, "Veh", JobVehID[playerid]); INI_Close(File); format(Job[JobID[playerid]][Name],64,"%s",JobName[playerid]); Job[JobID[playerid]][TCPX] = Pos[0]; Job[JobID[playerid]][TCPY] = Pos[1]; Job[JobID[playerid]][TCPZ] = Pos[2]; Job[JobID[playerid]][VehID] = JobVehID[playerid]; Job[JobID[playerid]][Choosed] = JobChoose[playerid]; Job[JobID[playerid]][Min] = JobMin[playerid]; Job[JobID[playerid]][Max] = JobMax[playerid]; Job[JobID[playerid]][Pickup] = CreateDynamicPickup(1239, 23, Job[JobID[playerid]][TCPX],Job[JobID[playerid]][TCPY],Job[JobID[playerid]][TCPZ],-1,-1,-1,100.0); format(string,128,""COL_LIGHTBLUE"To take job "COL_ORANGE"%s\n"COL_LIGHTBLUE"Type "COL_RED"[/takejob]",Job[JobID[playerid]][Name]); Job[JobID[playerid]][Label] = CreateDynamic3DTextLabel(string, 0xFFFFFF, Job[JobID[playerid]][TCPX],Job[JobID[playerid]][TCPY],Job[JobID[playerid]][TCPZ], 100, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100); new File:log = fopen("/Command.txt", io_write); format(string,sizeof(string),"YCMD:%s(playerid,params[],help)\r\n{\r\n#pragma unused help\r\n",inputtext); fwrite(log, string); format(string,sizeof(string),"if(P_Data[playerid][pJob] != %d) return SCM(playerid,COLOR_RED,\"EROR:\"COL_WHITE\"You are not %s\");\r\n",JobID[playerid]); fwrite(log, string); format(string,sizeof(string),"new pplayerid,price,Float:Position[3];\r\nif(sscanf(params,\"ui\",pplayerid,price)) return SCM(playerid,COLOR_RED,\"\"COL_WHITE\"Usage: /%s [Player ID/Part OfName] [Price]\");\r\n",inputtext); fwrite(log, string); fwrite(log, "if(!PlayerWork[playerid]) return SCM(playerid,COLOR_RED,\"EROR: \"COL_WHITE\"Type /startjob\");\r\n"); fwrite(log, "if(PlayerVeh[playerid] != GetPlayerVehicleID(playerid)) return SCM(playerid,COLOR_RED,\"EROR: \"COL_WHITE\"You are not in your vehicle\");\r\n"); fwrite(log, "if(pplayerid == INVALID_PLAYER_ID) return SCM(playerid,COLOR_RED,\"EROR:\"COL_WHITE\"Invalid ID\");\r\n"); fwrite(log, "GetPlayerPos(pplayerid,Position[0],Position[1],Position[2]);\r\n"); fwrite(log, "if(!IsPlayerInRangeOfPoint(playerid,5.0,Position[0],Position[1],Position[2])) return SCM(playerid,COLOR_RED,\"EROR:\"COL_WHITE\"You are not near to that player\");\r\n"); fwrite(log, "Seller[pplayerid] = playerid;\r\nPrice[pplayerid] = price;\r\n"); format(string,sizeof(string),"SendFormatMSG(pplayerid,-1,\"Player with job %s has you offered for price:",JobName[playerid]); fwrite(log, string); fwrite(log, " %d type /accept\",price);\r\n"); fwrite(log, "SCM(playerid,-1,\"Wait for player answer\");\r\n"); fwrite(log, "return 1;\r\n}\r\n==============In command /accept\r\n"); format(string,sizeof(string),"if(strcmp(text,\"%s\",false) == 0)\r\n{\r\n",inputtext); fwrite(log, string); fwrite(log, "if(Seller[playerid] == 999) return SCM(playerid,COLOR_RED,\"No body dosen't gave you some offer\");\r\n"); fwrite(log, "if(Price[playerid] > GetPlayerMoney(playerid)) return SCM(playerid,COLOR_RED,\"You don't have that money\"),Seller[playerid] = 999;\r\n"); fwrite(log, "SCM(Seller[playerid],-1,\"Player is accept offer\");\r\nSCM(playerid,-1,\"You are accept offer\");\r\n"); fwrite(log, "GivePlayerMoney(Seller[playerid],Price[playerid]);\r\nGivePlayerMoney(playerid,-Price[playerid]);\r\n"); fwrite(log, "new Float:health; GetPlayerHealth(playerid,health);\r\nSetPlayerHealth(playerid,health+25);\r\n"); fwrite(log, "}"); fclose(log); // Close the file } } return 0; } forward LoadPlayerData(playerid, name[], value[]); public LoadPlayerData(playerid, name[], value[]) { INI_Int("Job", P_Data[playerid][pJob]); return 1; } stock GetName(playerid) { new pName[MAX_PLAYER_NAME]; GetPlayerName(playerid, pName, MAX_PLAYER_NAME); return pName; } forward GetJobID(playerid); public GetJobID(playerid) { new Float:Distance; for(new j = 1; j<MAX_JOBS; j++) { Distance = GetDistanceToJob(playerid, j); if(Distance < 5.0) { return j; } } return -1; } forward Float:GetDistanceToJob(playerid, j); public Float:GetDistanceToJob(playerid, j) { new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2; GetPlayerPos(playerid,x1,y1,z1); x2 = Job[j][TCPX]; y2 = Job[j][TCPY]; z2 = Job[j][TCPZ]; return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2)); } forward LoadJobs(id, name[], value[]); public LoadJobs(id, name[], value[]) { new string[6]; INI_String("Name", Job[id][Name],64); INI_Float("TCPX", Job[id][TCPX]); INI_Float("TCPY", Job[id][TCPY]); INI_Float("TCPZ", Job[id][TCPZ]); INI_Int("Veh", Job[id][VehID]); INI_Int("Min", Job[id][Min]); INI_Int("Max", Job[id][Max]); INI_Int("Choose", Job[id][Choosed]); for(new i = 1;i <= MAX_CP;i++) { format(string,6,"CPX%d",i); INI_Float(string, CheckPoint[id][i][CPX]); format(string,6,"CPY%d",i); INI_Float(string, CheckPoint[id][i][CPY]); format(string,6,"CPZ%d",i); INI_Float(string, CheckPoint[id][i][CPZ]); } return 1; } //========Commands========= YCMD:createjob(playerid,params[],help) { #pragma unused help #pragma unused params new dFile[32]; if(!IsPlayerAdmin(playerid)) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"Need to be RCON admin!"); if(PlayerCreateJob[playerid]) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You already creating job!"); ShowPlayerDialog(playerid,DIALOG_JOB,DIALOG_STYLE_LIST,"Job bassed on","Checkpoints\nCommands","Choose","Close"); JobID[playerid] = 1; PlayerCreateJob[playerid] = true; for(new id = 1; id <= MAX_JOBS;id++) { format(dFile, 35, JOB_FILE, id); if(fexist(dFile)) JobID[playerid]++; if(JobID[playerid] > MAX_JOBS) return SCM(playerid,-1,"Change MAX_JOBS in FS for more jobs."); } return 1; } YCMD:finishcjob(playerid,params[],help) { #pragma unused help #pragma unused params if(!IsPlayerAdmin(playerid)) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"Need to be RCON admin!"); if(!PlayerCreateJob[playerid]) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You don't creating job!"); JobID[playerid] = 0; PlayerCreateJob[playerid] = false; SCM(playerid,-1,"You are finish creating job."); return 1; } new bool:TakeJobTimer; forward JobTimer( playerid ); YCMD:takejob(playerid,params[],help) { if(!TakeJobTimer) { #pragma unused help #pragma unused params new id = GetJobID(playerid); if(id == -1) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"There is no any job."); if( P_Data[playerid][pJob] != 0) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You already have job."); SendFormatMSG( playerid, -1, "Now your job is {E0941B}%s", Job[id][Name] ); P_Data[playerid][pJob] = id; TakeJobTimer = true; SetTimer( "JobTimer", 3000000, false ); }else return SendClientMessage(playerid, -1, "You must wait 30 minutes before doing another job again!"); return 1; } public JobTimer(playerid) { TakeJobTimer = false; return 1; } YCMD:startjob(playerid,params[],help) { #pragma unused help #pragma unused params if(PlayerWork[playerid]) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You are already start job. Type /finishjob"); new h = P_Data[playerid][pJob],Float:Pos[4]; GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]); GetPlayerFacingAngle(playerid,Pos[3]); if(P_Data[playerid][pJob] == 0) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You don't have job."); if(!IsPlayerInRangeOfPoint(playerid,20.0,Job[h][TCPX],Job[h][TCPY],Job[h][TCPZ])) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You are not near to your job."); PlayerCP[playerid] = 2; if(Job[h][Choosed] != 0) SetPlayerCheckpoint(playerid,CheckPoint[h][PlayerCP[playerid]][CPX],CheckPoint[h][PlayerCP[playerid]][CPY],CheckPoint[h][PlayerCP[playerid]][CPZ],3.0); SCM(playerid,-1,"You are start with job. Go to red checkpoint."); PlayerVeh[playerid] = CreateVehicle(Job[h][VehID],Pos[0],Pos[1]+1,Pos[2],Pos[3],random(256),random(256),3600); PlayerWork[playerid] = true; return 1; } YCMD:finishjob(playerid,params[],help) { #pragma unused help #pragma unused params if(!PlayerWork[playerid]) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You aren't start job."); if(P_Data[playerid][pJob] == 0) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You don't have job."); PlayerCP[playerid] = 0; DisablePlayerCheckpoint(playerid); SCM(playerid,-1,"You are finish with job."); DestroyVehicle(PlayerVeh[playerid]); PlayerWork[playerid] = false; return 1; } YCMD:quitjob(playerid,params[],help) { #pragma unused help #pragma unused params if(PlayerWork[playerid]) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"First finish work."); if(P_Data[playerid][pJob] == 0) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You don't have job."); SCM(playerid,-1,"You are quit from job."); P_Data[playerid][pJob] = 0; return 1; } YCMD:accept(playerid,params[],help) { #pragma unused help new text[48]; if(sscanf(params,"s[48]",text)) return SCM(playerid,-1,"/accept [Something]"); /* Other from command.txt */ return 1; }
Show me your lines
You have to add some lines like pawn Код:
|
GivePlayerMoney( playerid, 150000 );
if(Job[jobid][Choosed] == 2) { GivePlayerMoney(playerid,money); SendFormatMSG(playerid,-1,"You are get {E0941B}$%d",money); PlayerCP[playerid] = 0; DestroyVehicle(PlayerVeh[playerid]); SCM(playerid,-1,"You are finish your job!"); DisablePlayerCheckpoint(playerid); PlayerWork[playerid] = false; return 1; }