Cronwerks MCCode/MCCodes Forums

Please login or register.

Login with username, password and session length

News:

Have errors in your coding or want something specific added to your game? Check out our paid support here.


This forum is now closed and has moved to a new location! Click here to find out why.

AuthorTopic: [v1] Issue A Threat  (Read 1068 times)

Cyanide

  • Global Moderator
  • Basic Member
  • *****
  • Reputation Power: 38
  • Cyanide has no influence.
  • Offline Offline
  • Posts: 55
    • MSN Messenger - xcyanide187x@live.com
    • View Profile
[v1] Issue A Threat
« on: April 01, 2009, 03:23:32 AM »
What does this script do?

A player can issue a threat to another player to scare them, if the threat succeeds, the targeted player will lose all of their brave. If the threat fails, then the issuing player will lose theirs.

What does this mod require?

This mod requires a player to have full brave to attempt a threat. If the threat succeeds, the issuer will lose 1 brave per level. If it fails, the issuer will lose all brave.

Is this mod easy to install?

Yes, all you have to do is upload threat.php file and add a link to viewuser.php

threat.php
Code: [Select]
<?php
      
//-----------------------------------------------------------------------//
     //                                    Issue A Death Threat                                   //
    //               This is free code and can be modified or redistributed.            //
   //             Please do not try and sell this mod, it is meant to be FREE.       //
  //                     http://infintium.net - http://crime&chaos.com                //
 //                                      File Name: threat.php                               //
//------------------------------------------------------- --------------//
session_start();
require 
"global_func.php";
if(
$_SESSION['loggedin']==0) { header("Location: login.php");exit; }
$userid=$_SESSION['userid'];
require 
"header.php";
$h = new headers;
$h->startheaders();
include 
"mysql.php";
global 
$c;
$is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error());
$ir=mysql_fetch_array($is);
check_level();
$fm=money_formatter($ir['money']);
$cm=money_formatter($ir['crystals'],'');
$lv=date('F j, Y, g:i a',$ir['laston']);
$h->userdata($ir,$lv,$fm,$cm);
$h->menuarea();
$_POST['ID'] = abs((int) $_POST['ID']);
$_GET['ID'] = abs((int) $_GET['ID']);
if(
$_POST['ID'])
{
$q=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid={$_POST['ID']}",$c);
$r=mysql_fetch_array($q);
$chance rand(1,100);

  
//------------------------------------------------------------------//
 // DON'T EDIT ABOVE THIS LINE IF YOU DON'T KNOW WHAT YOU'RE DOING!! //
//------------------------------------------------------------------//                                                               
    //------------------------------------------------------------------------//
   //Change the next line to increase / decrease the success rate of a threat//
  //  The higher the number the better chance a player has to be successful //
 // eg. If the number is 60 then the player has a 59% chance of succeeding //
//------------------------------------------------------------------------//

if($chance 50)
{
//Change the following line to control how much brave someone will lose for failing a death threat//
$div rand(1,3);
$brave=$r['maxbrave']/$div;
mysql_query("UPDATE users SET brave=0 WHERE userid=$userid",$c);
//This is the event the target will recieve if the threat is failed//
event_add($r['userid'],"<a href='viewuser.php?u=$userid'>{$ir['username']}</a> pulled a gun and threatened your life, but your friends stepped in and scared them off.",$c);
//The following is the fail text//
print "<b>1.</b> You approach {$r['username']} with your weapon in hand. <br/><b>2.</b> You pull them into an alley and issue a death threat....<br/> <b>3.</b> Out of the corner of your eye you see {$r['username']}s friends enter the alley way.<br/><b>4.</b> Scared that they will beat you senceless you run away....<br/><br/>
<b>Result:</b> <font color='red'>Failed - You lose $brave bravery.</font><br/>"
;
}
else
{
//This is how much brave it will cost to perform a successful death threat//
$brave=$ir['level']*1;
mysql_query("UPDATE users SET brave=brave-$brave WHERE userid=$userid",$c);
mysql_query("UPDATE users SET brave=0 WHERE userid={$r['userid']}",$c);
//This is the event the target will recieve if the threat is successful//
event_add($r['userid'],"<a href='viewuser.php?u=$userid'>{$ir['username']}</a> put their gun to your head and threatened your life, causing you to lose all your brave.",$c);
//The following is the success text//
print "<b>1.</b> You approach {$r['username']} with your weapon in hand. <br/><b>2.</b> You pull them into an alley and wave it in their face after issueing a threat.<br/> <b>3.</b> {$r['username']} breaks out in a sweat and starts turning white.<br/>
<b>4.</b> Scared to death they turn and run away not to look back.<br/><br/>
<b>Result:</b> <font color='green'>Succeeded - {$r['username']} loses all their brave.</font><br/>"
;
}
}
else
{
$q=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid={$_GET['ID']}",$c);
if(
mysql_num_rows($q) == 0)
{
//Error message//
print "<b><font color='red'>ERROR:</b></font> Invalid User ID.<br/><br/>
<a href='index.php'>-Go Home</a>"
;
}
else
{
$r=mysql_fetch_array($q);
//This is how much brave it will cost to issue a threat (printed on the confirm page)//
$brave=$ir['level']*1;
//This is the text printed on the confirm page//
if($ir['brave'] >= $ir['maxbrave'])
{
print 
"You are about to issue a death threat to <b>{$r['username']}</b>, this will cost you $brave brave.<br /><br/>
<form action='threat.php' method='post'><input type='hidden' name='ID' value='{$_GET['ID']}' /><input type='submit' value='Issue Death Threat' /></form>"
;
}
else
{
//Error Message//
print "<b><font color='red'>ERROR:</font></b> You must have maximum bravery to use this feature.<br/><br/><a href='index.php'>-Go Home</a>";
}
}
}
$h->endpage();
?>

Add this link to viewuser.php:
Code: [Select]
[<a href='threat.php?ID={$r['userid']}'>Issue a Threat</a>]
And you're done.
Logged

Mr Teller

  • Basic Member
  • *
  • Reputation Power: 3
  • Mr Teller has no influence.
  • Offline Offline
  • Posts: 4
    • View Profile
    • Email
Re: [v1] Issue A Threat
« Reply #1 on: April 16, 2009, 06:18:42 PM »
Good mod Cyanide....i saw this mod on ce and installed it and it works good....Players like takeing peoples will
Logged

vlad

  • Basic Member
  • *
  • Reputation Power: 3
  • vlad has no influence.
  • Offline Offline
  • Posts: 7
    • View Profile
    • WWW
    • Email
Re: [v1] Issue A Threat
« Reply #2 on: January 01, 2010, 05:45:58 AM »
Im preety sure That it will take 5minuets to convert it to v2
Logged
 


This forum is now closed and has moved to a new location! Click here to find out why.