All pastes #792920 Raw Edit

Insurance Code

public text v1 · immutable
·published 2007-11-21 20:29 UTC
rendered paste body
Top Of Script:
new File:Insurance;


Forwards:
forward Insurance_Pay(playerid);
forward Insurance_Get(playerid);
forward INSURANCEPAY(playerid);
forward SETJAIL(playerid);
forward UNJAIL(playerid);

OnFilterScriptInIt():
SetTimer("INSURANCEPAY", 60000, 1);


Publics(ANYWHEREINSCRIPT):
public INSURANCEPAY(playerid)
{
    new string[256];
    format(string, sizeof(string), "SERVER: You have 15 seconds to Pay your insurance or jail");
	SendClientMessage(playerid, COLOR_YELLOW, string);
	SetTimer("SETJAIL",15000,0);
	return 1;
}
public SETJAIL(playerid)
{
new string[256];
SetPlayerInterior(playerid,3);
jailed[playerid] = 1;
SetPlayerPos(playerid,198.3797,160.8905,1003.0300);
SetPlayerFacingAngle(playerid,177.0350);
SetCameraBehindPlayer(playerid);
PlayerPlaySound(playerid,1082,198.3797,160.8905,1003.0300);
TogglePlayerControllable(playerid,0);
format(string, sizeof(string), "SERVER: You will be unjailed in 15 seconds");
SendClientMessage(playerid, COLOR_YELLOW, string);
SetTimer("UNJAIL",15000,0);
return 1;
}
public UNJAIL(playerid)
{
jailed[playerid] = 0;
SetPlayerInterior(playerid,0);
SetPlayerFacingAngle(playerid,90.00);
SetPlayerPos(playerid,2296.4031,2468.7754,10.8203);
SetPlayerFacingAngle(playerid,177.0350);
SetCameraBehindPlayer(playerid);
TogglePlayerControllable(playerid,1);
return 1;
}

OnPlayerCommandText:
if(strcmp(cmd, "/payinsurance", true) == 0) {//payinsurance Command
                if(IsPlayerConnected(playerid)){
             	GetPlayerName(playerid, PName, sizeof(PName));
              	Insurance=fopen("Insurance",io_readwrite);
               	format(string, sizeof(string), "%s (ID:%d) has Paid His Car Insurance",PName,playerid);
               	SendClientMessageToAll(0xFF800000,string);
               	Insurance_Pay(playerid);
               	UNJAIL(playerid);
               	INSURANCEPAY(playerid);
			   	return 1;
               	}else{
        format(string, sizeof(string), " You need to be connected to pay insurance!!",playerid);
		SendClientMessage(playerid, COLOR_YELLOW, string);
	}
				return 1;
}

if(strcmp(cmd, "/getinsurance", true) == 0) {//getinsurance Command
                if(IsPlayerConnected(playerid)){
                if (Agent[playerid] == 1) {
             	GetPlayerName(playerid, PName, sizeof(PName));
              	Insurance=fopen("Insurance",io_readwrite);
                format(string, sizeof(string), "Insurance Agent:%s (ID:%d) has Collected the Insurance money",PName,playerid);
                SendClientMessageToAll(0xFF800000,string);
                Insurance_Get(playerid);
                return 1;
			    }else{
        format(string, sizeof(string), " You need to be an insurance agent to get the Money",playerid);
		SendClientMessage(playerid, COLOR_YELLOW, string);
		}
                }else{
        format(string, sizeof(string), " You need to be connected to Get insurance!!",playerid);
		SendClientMessage(playerid, COLOR_YELLOW, string);
}
				return 1;
}

if(strcmp(cmd, "/iholdyourmoney", true) == 0) {
		SendClientMessage(playerid, COLOR_WHITE, "SERVER:Your are now a Insurance Agent:");
		SendClientMessage(playerid, COLOR_YELLOW, "Your Commands Are: /getinsurance");
        Agent[playerid] = 1;
        TogglePlayerControllable(playerid,1);
		SetPlayerColor(playerid, COLOR_WHITE);
		return 1;
	}



TROUBLESOME PART OF THE SCIRPT________))))))))
public Insurance_Pay(playerid)
{
    new player[24];
	GetPlayerName(playerid,player,24);
	Insurance=fopen("Insurance",io_readwrite);
	dini_IntSet(player,"money",Insurance + 500);
    fclose(Insurance);
    return 1;
}
public Insurance_Get(playerid)
{
    new player[24];
    new tmp[255]; //create a variable
	tmp = dini_Get(player,"money"); //assign tmp the returned value
	GivePlayerMoney(playerid,strval(tmp)); //give the amount in variable(tmp) to playerid
	return 1;
}