Nieuw lid |
|
Hey,
Ik ben bezig met een script te maken voor mijn gameserver(MTA SA)
Nu maak ik een soort van script waar je maps kan kopen.
//Command: !buymap
if ($command == "!buymap" || $command == "!jukebox") {
$row = mysql_fetch_assoc(mysql_query("SELECT cash FROM player WHERE nick='".$nick."'"));
if ($row['cash'] < 100) {
$this->privateMessage($playerID, 'You cannot buy this map because you dont have the cash. Your Cash now: '.$row['cash'].'$');
}
else {
$count = 0;
$msg = NULL;
foreach ($messageex as $item) {
if ($count > 0) {
$msg .= $item." ";
}
$count++;
}
$msg = substr($msg, 0, -1);
$_SESSION['jukebox'] = array();
$map = $msg;
$mapid = NULL;
foreach ($this->maps as $id => $item) {
if ($item == $map) {
$mapid = $id;
break;
}
}
if (strlen($mapid) == 0) {
$this->privateMessage($playerID, "There were no matching results!");
} else {
$nick = $this->GetPlayerName($playerID);
if (TAB.count($this->players) > 1) {
mysql_query("UPDATE player SET cash=cash-100 WHERE nick='".$nick."'");
array_push($_SESSION['jukebox'], array($nick, substr($mapid, 0, -2)));
$this->message($nick." has bought ".$map);
}
else {
array_push($_SESSION['jukebox'], array($nick, substr($mapid, 0, -2)));
$this->message($nick." has bought ".$map." for free. Only 1 player online");
}
}
}
}
//Command: !buymap if ($command == "!buymap" || $command == "!jukebox") { if ($row['cash'] < 100) { $this->privateMessage($playerID, 'You cannot buy this map because you dont have the cash. Your Cash now: '.$row['cash'].'$'); } else { $count = 0; $msg = NULL; foreach ($messageex as $item) { if ($count > 0) { $msg .= $item." "; } $count++; } $_SESSION['jukebox'] = array(); $map = $msg; $mapid = NULL; foreach ($this->maps as $id => $item) { if ($item == $map) { $mapid = $id; break; } } $this->privateMessage($playerID, "There were no matching results!"); } else { $nick = $this->GetPlayerName($playerID); if (TAB .count($this->players) > 1) { mysql_query("UPDATE player SET cash=cash-100 WHERE nick='".$nick."'"); $this->message($nick." has bought ".$map); } else { $this->message($nick." has bought ".$map." for free. Only 1 player online"); } } } }
hij moet bij de command !buymap een array toevoegen in jukebox.
Voor 1 map werkt het maar eens er nog mensen mappen kopen blijkt dat ze elkaar overschrijven...
Ziet iemand de fout?
Alvast Bedankt
Jelle.
|