View Single Post
  #4  
Old 12-19-2011, 03:59 PM
Trakan Trakan is offline
It's all about cats!
Trakan's Avatar
Join Date: Sep 2010
Location: France
Posts: 64
Trakan is an unknown quantity at this point
Quote:
Originally Posted by Tolnaftate2004 View Post
  1. You can't modify clientr variables on the client-side. You can perform tests with client variables, but for security reasons, you will want to use clientr variables, which means you will have to modify them on the server-side. If you don't know what I mean, I'm sure someone will post a link here for you. Otherwise, look into triggeraction, triggerclient, and triggerserver if you're not already familiar.
  2. Because clientr.ammo is unchanged, it is 0. Then, when you check if clientr.ammo < 0 (which, I am assuming should in fact be '>'), that test fails.
  3. You are mixing GS1 and GS2, which is bad form.

    To set the player's chat, use player.chat = "foo".
    To set the player's attributes (like #P2), use player.attr[2] = "bar".
    To replace a GANI, use replaceani("baz","qux").
  4. Use = as assignment only and use == as comparison only (see the 3rd line in your code). The engine will fix this for you, but it is bad practice.
  5. You will only need one //#CLIENTSIDE.
Done, except first step.
Now i have that :
PHP Code:
//#CLIENTSIDE
function onPlayerChats() {
if (
player.chat == "/ammo"){
  
clientr.ammo += 10;
  
clientr.capacityammo 5;
  
clientr.maxcapacityammmo 5;
  
setplayerprop #P2,holst_usp45.png;
  
replaceani ("walk","holst_gunwalk");
  
replaceani ("idle","holst_gunidle");
  
setplayerprop #c,Ammo added;
}
}
function 
onWeaponFired() {
  if (
clientr.ammo && clientr.capacityammo != 0) {
  
shoot(player.vecx(player.dir), player.vecy(player.dir), player.z, (playerdir 1) * pi 2NULLNULL"holst_bullet"NULL);
  
setani("holst_gunfire"NULL);
  
clientr.ammo -= 1;
  
clientr.capacityammo -= 5;
  
freezeplayer(0.75);
} else {
player.chat "No Ammo!";
}
}
if (
clientr.ammo == 0) {
player.chat "No Ammo!";
}
function 
onActionProjectile() {
  
player.hearts -= 6;
}
function 
onKeyPressedcodekey )
{
  if ( 
key == "e" || key == "E" )
  {
setani("holst_gunreload"NULL);
}

And Gunderak, where i add this code?
Reply With Quote